Package org.onosproject.net.resource
Class ContinuousResource
- java.lang.Object
-
- org.onosproject.net.resource.ContinuousResource
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ContinuousResourcechild(java.lang.Class<?> child, double value)Returns a child resource of this instance with specifying a child object and value.DiscreteResourcechild(java.lang.Object child)Returns a child resource of this instance with specifying the child object.booleanequals(java.lang.Object obj)inthashCode()ContinuousResourceIdid()Returns the ID of this resource.booleanisSubTypeOf(java.lang.Class<?> ancestor)Checks if the type of this instance is the sub-type of the specified type.booleanisTypeOf(java.lang.Class<?> type)Checks if the type of this instance is the specified type.java.util.Optional<DiscreteResource>parent()Returns the parent resource of this instance.java.lang.StringsimpleTypeName()Returns the simple type name of this resource.java.lang.StringtoString()doublevalue()Returns the value of the resource amount.<T> java.util.Optional<T>valueAs(java.lang.Class<T> type)Returns value interpreted as the specified type.
-
-
-
Method Detail
-
id
public ContinuousResourceId id()
Description copied from interface:ResourceReturns the ID of this resource.
-
simpleTypeName
public java.lang.String simpleTypeName()
Description copied from interface:ResourceReturns the simple type name of this resource. Example:
Resource: DeviceId:1/PortNumber:1/VlanId:200
Simple type name: VlanId- Specified by:
simpleTypeNamein interfaceResource- Returns:
- the simple type name of this resource
-
isTypeOf
public boolean isTypeOf(java.lang.Class<?> type)
Description copied from interface:ResourceChecks if the type of this instance is the specified type.
-
value
public double value()
Returns the value of the resource amount.- Returns:
- the value of the resource amount
-
isSubTypeOf
public boolean isSubTypeOf(java.lang.Class<?> ancestor)
Description copied from interface:ResourceChecks if the type of this instance is the sub-type of the specified type.- Specified by:
isSubTypeOfin interfaceResource- Parameters:
ancestor- type of resource to be checked.- Returns:
- true if this resource is under the resource whose type is the given type.
-
valueAs
public <T> java.util.Optional<T> valueAs(java.lang.Class<T> type)
Returns value interpreted as the specified type. If the specified type is incompatible with the underlying value, an empty instance is returned. A user must specify Double.class or double.class to avoid an empty value.
-
child
public DiscreteResource child(java.lang.Object child)
Description copied from interface:ResourceReturns a child resource of this instance with specifying the child object. It is not allowed that a continuous type resource has a child. If the instance is ContinuousResource,UnsupportedOperationExceptionis thrown. If the given object is aClassinstance,IllegalArgumentExceptionis thrown.
-
child
public ContinuousResource child(java.lang.Class<?> child, double value)
Description copied from interface:ResourceReturns a child resource of this instance with specifying a child object and value. It is not allowed that a continuous type resource has a child. If the instance is ContinuousResource,UnsupportedOperationExceptionis thrown.
-
parent
public java.util.Optional<DiscreteResource> parent()
Description copied from interface:ResourceReturns the parent resource of this instance. E.g. if this resource is Link:1/VLAN ID:100, the return value is the resource for Link:1.
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-