Interface Resource

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static Resource NULL
      An attribute that implements the Null Object Design Pattern for Resource objects.
    • Method Summary

      Modifier and Type Method Description
      long getAllocatedResource()
      Gets the current total amount of allocated resource.
      long getAvailableResource()
      Gets the amount of the resource that is available (free).
      default double getPercentUtilization()
      Gets the current percentage of resource utilization in scale from 0 to 1.
      default boolean isAmountAvailable​(double amountToCheck)
      Checks if there is a specific amount of resource available (free), where such amount is a double value that will be converted to long.
      boolean isAmountAvailable​(long amountToCheck)
      Checks if there is a specific amount of resource available (free).
      default boolean isAmountAvailable​(Resource resource)
      Checks if there the capacity required for the given resource is available (free) at this resource.
      default boolean isFull()
      Checks if the resource is full or not.
      default boolean isObjectSubClassOf​(java.lang.Class classWanted)
      Checks if this object is instance of a given class.
      static boolean isObjectSubClassOf​(java.lang.Object object, java.lang.Class classWanted)
      Checks if a given object is instance of a given class.
    • Field Detail

      • NULL

        static final Resource NULL
        An attribute that implements the Null Object Design Pattern for Resource objects.
    • Method Detail

      • isObjectSubClassOf

        static boolean isObjectSubClassOf​(java.lang.Object object,
                                          java.lang.Class classWanted)
        Checks if a given object is instance of a given class.
        Parameters:
        object - the object to check
        classWanted - the class to verify if the object is instance of
        Returns:
        true if the object is instance of the given class, false otherwise
      • isObjectSubClassOf

        default boolean isObjectSubClassOf​(java.lang.Class classWanted)
        Checks if this object is instance of a given class.
        Parameters:
        classWanted - the class to verify if the object is instance of
        Returns:
        true if the object is instance of the given class, false otherwise
      • getAvailableResource

        long getAvailableResource()
        Gets the amount of the resource that is available (free).
        Returns:
        the amount of available resource
      • getAllocatedResource

        long getAllocatedResource()
        Gets the current total amount of allocated resource.
        Returns:
        amount of allocated resource
      • isAmountAvailable

        default boolean isAmountAvailable​(Resource resource)
        Checks if there the capacity required for the given resource is available (free) at this resource. This method is commonly used to check if there is a specific amount of resource free at a physical resource (this Resource instance) that is required by a virtualized resource (the given Resource).
        Parameters:
        resource - the resource to check if its capacity is available at the current resource
        Returns:
        true if the capacity required by the given Resource is free; false otherwise
        See Also:
        isAmountAvailable(long)
      • isAmountAvailable

        boolean isAmountAvailable​(long amountToCheck)
        Checks if there is a specific amount of resource available (free).
        Parameters:
        amountToCheck - the amount of resource to check if is free.
        Returns:
        true if the specified amount is free; false otherwise
      • isAmountAvailable

        default boolean isAmountAvailable​(double amountToCheck)
        Checks if there is a specific amount of resource available (free), where such amount is a double value that will be converted to long.

        This method is just a shorthand to avoid explicitly converting a double to long.

        Parameters:
        amountToCheck - the amount of resource to check if is free.
        Returns:
        true if the specified amount is free; false otherwise
        See Also:
        isAmountAvailable(long)
      • isFull

        default boolean isFull()
        Checks if the resource is full or not.
        Returns:
        true if the storage is full, false otherwise
      • getPercentUtilization

        default double getPercentUtilization()
        Gets the current percentage of resource utilization in scale from 0 to 1. It is the percentage of the total resource capacity that is currently allocated.
        Returns:
        current resource utilization (allocation) percentage in scale from 0 to 1