Class Range<N extends java.lang.Number>


  • public class Range<N extends java.lang.Number>
    extends java.lang.Object
    A simple numeric range. Minimum value is included, maximum value is excluded.
    Author:
    Pinaki Poddar
    • Constructor Summary

      Constructors 
      Constructor Description
      Range​(java.lang.Object min, java.lang.Object max)  
      Range​(N min, N max)
      Creates a range.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean adjust​(N x)
      Adjusts this range by the given number.
      boolean contains​(java.lang.Number x)
      Affirms if the given value is within this range.
      <X extends java.lang.Number>
      boolean
      contains​(Range<X> r)
      Affirms if the given range is within this range.
      boolean equals​(java.lang.Object obj)  
      N getMaximum()
      Gets the maximum value.
      N getMinimum()
      Gets the minimum value.
      int hashCode()  
      java.lang.Class<N> type()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Range

        public Range​(java.lang.Object min,
                     java.lang.Object max)
      • Range

        public Range​(N min,
                     N max)
        Creates a range. Empty range i.e. where minimum equals maximum is allowed.
        Parameters:
        min - non-null minimum value.
        max - non-null maximum value.
    • Method Detail

      • type

        public java.lang.Class<N> type()
      • contains

        public boolean contains​(java.lang.Number x)
        Affirms if the given value is within this range. Minimum is included, maximum is excluded.
        Parameters:
        x - a non-null value
        Returns:
        true if the given value is greater than or equals to minimum and less than the maximum.
      • contains

        public <X extends java.lang.Number> boolean contains​(Range<X> r)
        Affirms if the given range is within this range. Minimum is included, maximum is excluded.
        Parameters:
        x - a non-null value
        Returns:
        true if the given value is greater than or equals to minimum and less than the maximum.
      • getMinimum

        public N getMinimum()
        Gets the minimum value.
      • getMaximum

        public N getMaximum()
        Gets the maximum value.
      • adjust

        public boolean adjust​(N x)
        Adjusts this range by the given number.
        Parameters:
        x - a non-null value.
        Returns:
        if this range is adjusted by this value.
      • 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