Class RangeUtil


  • public final class RangeUtil
    extends Object
    A utility class for Ranges.
    • Field Detail

      • DEFAULT_FULLY_CONTAINED

        public static final boolean DEFAULT_FULLY_CONTAINED
        See Also:
        Constant Field Values
    • Method Detail

      • inRange

        public static <T extends Comparable<T>> boolean inRange​(Comparable<T> startValue,
                                                                Comparable<T> endValue,
                                                                T rangeStart,
                                                                T rangeEnd,
                                                                Boolean startInclusive,
                                                                Boolean endInclusive)
        Checks the start and end values within a provided range.
        Type Parameters:
        T - the type of the range
        Parameters:
        startValue - the start value to test
        endValue - the end value to test
        rangeStart - the start of the defined allowed range
        rangeEnd - the end of the defined allowed range
        startInclusive - true if the start of the range is inclusive
        endInclusive - true if the end of the range is inclusive
        Returns:
        true if the start and end values are within the range.
      • inRange

        public static <T extends Comparable<T>> boolean inRange​(Comparable<T> startValue,
                                                                Comparable<T> endValue,
                                                                T rangeStart,
                                                                T rangeEnd,
                                                                Boolean startInclusive,
                                                                Boolean endInclusive,
                                                                Boolean startFullyContained,
                                                                Boolean endFullyContained)
        Checks the start and end values within a provided range.
        Type Parameters:
        T - the type of the range
        Parameters:
        startValue - the start value to test
        endValue - the end value to test
        rangeStart - the start of the defined allowed range
        rangeEnd - the start of the defined allowed range
        startInclusive - true if the start of the range is inclusive
        endInclusive - true if the end of the range is inclusive
        startFullyContained - true if the start of the range is fully contained
        endFullyContained - true if the end of the range is fully contained
        Returns:
        true if the start and end values are within the range.