Class DiscreteResource

  • All Implemented Interfaces:
    Resource

    @Beta
    public final class DiscreteResource
    extends java.lang.Object
    implements Resource
    Represents a resource path which specifies a resource which can be measured as a discrete unit. A VLAN ID and a MPLS label of a link are examples of the resource.
    • Field Summary

      • Fields inherited from interface org.onosproject.net.resource.Resource

        ROOT
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      ContinuousResource child​(java.lang.Class<?> child, double value)
      Returns a child resource of this instance with specifying a child object and value.
      DiscreteResource child​(java.lang.Object child)
      Returns a child resource of this instance with specifying the child object.
      boolean equals​(java.lang.Object obj)  
      int hashCode()  
      DiscreteResourceId id()
      Returns the ID of this resource.
      boolean isSubTypeOf​(java.lang.Class<?> ancestor)
      Checks if the type of this instance is the sub-type of the specified type.
      boolean isTypeOf​(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.String simpleTypeName()
      Returns the simple type name of this resource.
      java.lang.String toString()  
      <T> java.util.Optional<T> valueAs​(java.lang.Class<T> type)
      Returns value interpreted as the specified type.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Method Detail

      • id

        public DiscreteResourceId id()
        Description copied from interface: Resource
        Returns the ID of this resource.
        Specified by:
        id in interface Resource
        Returns:
        the ID of this resource
      • simpleTypeName

        public java.lang.String simpleTypeName()
        Description copied from interface: Resource
        Returns the simple type name of this resource. Example:
        Resource: DeviceId:1/PortNumber:1/VlanId:200
        Simple type name: VlanId
        Specified by:
        simpleTypeName in interface Resource
        Returns:
        the simple type name of this resource
      • isTypeOf

        public boolean isTypeOf​(java.lang.Class<?> type)
        Description copied from interface: Resource
        Checks if the type of this instance is the specified type.
        Specified by:
        isTypeOf in interface Resource
        Parameters:
        type - type of resource to be checked
        Returns:
        true if this resource is the type of the specified type. Otherwise, false.
      • isSubTypeOf

        public boolean isSubTypeOf​(java.lang.Class<?> ancestor)
        Description copied from interface: Resource
        Checks if the type of this instance is the sub-type of the specified type.
        Specified by:
        isSubTypeOf in interface Resource
        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)
        Description copied from interface: Resource
        Returns value interpreted as the specified type. If the specified type is incompatible with the underlying value, an empty instance is returned.
        Specified by:
        valueAs in interface Resource
        Type Parameters:
        T - type of the return value
        Parameters:
        type - class instance specifying the type of return value
        Returns:
        the value of this resource as the specified type. If type mismatches, returns an empty instance.
      • child

        public DiscreteResource child​(java.lang.Object child)
        Description copied from interface: Resource
        Returns 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, UnsupportedOperationException is thrown. If the given object is a Class instance, IllegalArgumentException is thrown.
        Specified by:
        child in interface Resource
        Parameters:
        child - child object
        Returns:
        a child resource
      • child

        public ContinuousResource child​(java.lang.Class<?> child,
                                        double value)
        Description copied from interface: Resource
        Returns 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, UnsupportedOperationException is thrown.
        Specified by:
        child in interface Resource
        Parameters:
        child - child object
        value - value
        Returns:
        a child resource
      • parent

        public java.util.Optional<DiscreteResource> parent()
        Description copied from interface: Resource
        Returns 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.
        Specified by:
        parent in interface Resource
        Returns:
        the parent resource of this instance. If there is no parent, empty instance will be returned.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object