Class Resource<T extends Resource<T>>
- java.lang.Object
-
- org.apache.flink.api.common.resources.Resource<T>
-
- All Implemented Interfaces:
Serializable
,Comparable<Resource>
- Direct Known Subclasses:
CPUResource
,ExternalResource
@Internal public abstract class Resource<T extends Resource<T>> extends Object implements Serializable, Comparable<Resource>
Base class for resources one can specify. Notice that the scale of value will be limited toMAX_VALUE_SCALE
and all the trailing zeros will be stripped for readability.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
Resource(String name, double value)
protected
Resource(String name, BigDecimal value)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description int
compareTo(Resource other)
protected abstract T
create(BigDecimal value)
Create a new instance of the sub resource.T
divide(int by)
T
divide(BigDecimal by)
boolean
equals(Object o)
String
getName()
BigDecimal
getValue()
int
hashCode()
boolean
isZero()
T
merge(T other)
T
multiply(int multiplier)
T
multiply(BigDecimal multiplier)
T
subtract(T other)
String
toString()
-
-
-
Constructor Detail
-
Resource
protected Resource(String name, double value)
-
Resource
protected Resource(String name, BigDecimal value)
-
-
Method Detail
-
multiply
public T multiply(BigDecimal multiplier)
-
multiply
public T multiply(int multiplier)
-
divide
public T divide(BigDecimal by)
-
divide
public T divide(int by)
-
compareTo
public int compareTo(Resource other)
- Specified by:
compareTo
in interfaceComparable<T extends Resource<T>>
-
getName
public String getName()
-
getValue
public BigDecimal getValue()
-
isZero
public boolean isZero()
-
create
protected abstract T create(BigDecimal value)
Create a new instance of the sub resource.- Parameters:
value
- The value of the resource- Returns:
- A new instance of the sub resource
-
-