Class Range<T>

  • Type Parameters:
    T - The value of the range.
    All Implemented Interfaces:
    tech.uom.lib.common.function.MaximumSupplier<T>, tech.uom.lib.common.function.MinimumSupplier<T>
    Direct Known Subclasses:
    QuantityRange

    public abstract class Range<T>
    extends java.lang.Object
    implements tech.uom.lib.common.function.MinimumSupplier<T>, tech.uom.lib.common.function.MaximumSupplier<T>
    A Range is a pair of T items that represent a range of values.

    Subclasses of Range should be immutable.

    Since:
    1.0
    Version:
    1.0, December 29, 2017
    See Also:
    Wikipedia: Range
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private T max  
      private T min  
      private T res  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected Range​(T min, T max)
      Construct an instance of Range with a min and max value.
      protected Range​(T min, T max, T res)
      Construct an instance of Range with a min, max and res value.
    • Field Detail

      • min

        private final T min
      • max

        private final T max
      • res

        private T res
    • Constructor Detail

      • Range

        protected Range​(T min,
                        T max,
                        T res)
        Construct an instance of Range with a min, max and res value.
        Parameters:
        min - The minimum value for the range.
        max - The maximum value for the range.
        res - The resolution of the range.
      • Range

        protected Range​(T min,
                        T max)
        Construct an instance of Range with a min and max value.
        Parameters:
        min - The minimum value for the range.
        max - The maximum value for the range.
    • Method Detail

      • getMinimum

        public T getMinimum()
        Returns the smallest value of the range. The value is the same as that given as the constructor parameter for the smallest value.
        Specified by:
        getMinimum in interface tech.uom.lib.common.function.MinimumSupplier<T>
        Returns:
        the minimum value
      • getMaximum

        public T getMaximum()
        Returns the largest value of the range. The value is the same as that given as the constructor parameter for the largest value.
        Specified by:
        getMaximum in interface tech.uom.lib.common.function.MaximumSupplier<T>
        Returns:
        the maximum value
      • getResolution

        public T getResolution()
        Returns the resolution of the range. The value is the same as that given as the constructor parameter for the largest value.
        Returns:
        resolution of the range, the value is the same as that given as the constructor parameter for the resolution
      • hasMinimum

        public boolean hasMinimum()
        Method to easily check if getMinimum() is not null.
        Returns:
        true if getMinimum() is not null .
      • hasMaximum

        public boolean hasMaximum()
        Method to easily check if getMaximum() is not null.
        Returns:
        true if getMaximum() is not null.
      • contains

        public abstract boolean contains​(T t)
        Checks whether the given T is within this range
        Parameters:
        t -
        Returns:
        true if the value is within the range
      • equals

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

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

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