Class DoubleRange

  • All Implemented Interfaces:
    INumberRange

    public class DoubleRange
    extends Object
    implements INumberRange
    The DoubleRange class stores range of floats. Examples : "1.2-3", "2 .. 4", "123.456 ... 1000.00001" (Important: using of ".." and "..." requires spaces between numbers and separator).
    • Constructor Detail

      • DoubleRange

        public DoubleRange​(double range)
      • DoubleRange

        public DoubleRange​(double lowerBound,
                           double upperBound)
      • DoubleRange

        public DoubleRange()
      • DoubleRange

        public DoubleRange​(String range)
    • Method Detail

      • isTruncated

        protected static boolean isTruncated​(Number from,
                                             double to)
        Returns true if converted value is truncated
        Parameters:
        from - converting number
        to - converted double value
        Returns:
        true if converted value is truncated
      • compareLowerBound

        public int compareLowerBound​(DoubleRange range)
        Compares lower bounds.
        Parameters:
        range - the DoubleRange to be compared
        Returns:
        a negative integer, zero, or a positive integer as lower bound of this range is less than, equal to, or greater than the lower bound of specified range.
      • compareUpperBound

        public int compareUpperBound​(DoubleRange range)
        Compares upper bounds.
        Parameters:
        range - the DoubleRange to be compared
        Returns:
        a negative integer, zero, or a positive integer as upper bound of this range is less than, equal to, or greater than the upper bound of specified range.
      • contains

        public boolean contains​(double x)
      • contains

        public boolean contains​(DoubleRange range)
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • getLowerBound

        public double getLowerBound()
        Returns:
        Returns the lowerBound.
      • getUpperBound

        public double getUpperBound()
        Returns:
        Returns the upperBound.
      • setLowerBound

        public void setLowerBound​(double lowerBound)
        Parameters:
        lowerBound - The lowerBound to set.
      • setUpperBound

        public void setUpperBound​(double upperBound)
        Parameters:
        upperBound - The upperBound to set.
      • distance

        public static int distance​(byte x,
                                   DoubleRange y)
      • distance

        public static int distance​(short x,
                                   DoubleRange y)
      • distance

        public static int distance​(int x,
                                   DoubleRange y)
      • distance

        public static int distance​(long x,
                                   DoubleRange y)
      • distance

        public static int distance​(float x,
                                   DoubleRange y)
      • distance

        public static int distance​(double x,
                                   DoubleRange y)