Class Interval<T extends Number & Comparable<? super T>>

    • Constructor Detail

      • Interval

        public Interval​(Interval.Closure closure,
                        T leftMargin,
                        T rightMargin)
        Creates a new interval
        Parameters:
        closure - the closure of the interval
        leftMargin - the lower bound of the interval
        rightMargin - the upper bound of the interval
    • Method Detail

      • openClosed

        public static <T extends Number & Comparable<? super T>> Interval<T> openClosed​(T left,
                                                                                        T right)
        Creates an interval (left,right]
        Parameters:
        left - the left
        right - the right
        Returns:
        an internal (left,right]
      • openOpen

        public static <T extends Number & Comparable<? super T>> Interval<T> openOpen​(T left,
                                                                                      T right)
        Creates an interval (left,right)
        Parameters:
        left - the left
        right - the right
        Returns:
        an internal (left,right)
      • closedOpen

        public static <T extends Number & Comparable<? super T>> Interval<T> closedOpen​(T left,
                                                                                        T right)
        Creates an interval [left,right)
        Parameters:
        left - the left
        right - the right
        Returns:
        an internal [left,right)
      • closedClosed

        public static <T extends Number & Comparable<? super T>> Interval<T> closedClosed​(T left,
                                                                                          T right)
        Creates an interval [left,right]
        Parameters:
        left - the left
        right - the right
        Returns:
        an internal [left,right]
      • getClosure

        public Interval.Closure getClosure()
        Returns the closure of the interval
        Returns:
        the closure of the interval
      • getLeftMargin

        public T getLeftMargin()
        Returns the lower bound of the interval
        Returns:
        the lower bound of the interval
      • getRightMargin

        public T getRightMargin()
        Returns the upper bound of the interval
        Returns:
        the upper bound of the interval
      • getNumericType

        public Class<?> getNumericType()
      • equals

        public boolean equals​(Object o)
        Two intervals are equal if they have the same lower bound, upper bound, and closure.
        Overrides:
        equals in class Object
      • hashCode

        public int hashCode()
        Returns hashCode consistent with equals.
        Overrides:
        hashCode in class Object
      • compareTo

        public int compareTo​(Interval<T> o)
        First compares the left margins, then the right margins. Closure is not considered when comparing intervals.
        Specified by:
        compareTo in interface Comparable<T extends Number & Comparable<? super T>>
      • toString

        public String toString()
        Returns a pretty-printed string of the form [lower,upper]
        Overrides:
        toString in class Object