Interface Range<N>

    • Method Detail

      • getMin

        N getMin()
      • getMax

        N getMax()
      • isMinInclusive

        boolean isMinInclusive()
      • isMaxInclusive

        boolean isMaxInclusive()
      • intersects

        boolean intersects​(Range<N> other)
        Check if the given range intersects the current range.
        Parameters:
        other - the range to check against the current range
        Returns:
        true if both ranges intersect and false otherwise
      • contains

        boolean contains​(N value)
        Check if a given value is contained within this range
        Parameters:
        value - the value to check
        Returns:
        true if the value is contained by this range and false otherwise
      • withMin

        Range<N> withMin​(N min)
        Create a copy of the current range with the given min value.
        Parameters:
        min - the new min value for the copy
        Returns:
        a copy of the current range
      • withMax

        Range<N> withMax​(N max)
        Create a copy of the current range with the given max value.
        Parameters:
        max - the new max value for the copy
        Returns:
        a copy of the current range
      • withMinInclusive

        Range<N> withMinInclusive​(boolean minInclusive)
        Create a copy of the current range where the min value will be either inclusive or exclusive.
        Parameters:
        minInclusive - boolean indicating if the min value should be inclusive or exclusive
        Returns:
        a copy of the current range
      • withMaxInclusive

        Range<N> withMaxInclusive​(boolean maxInclusive)
        Create a copy of the current range where the max value will be either inclusive or exclusive.
        Parameters:
        maxInclusive - boolean indicating if the max value should be inclusive or exclusive
        Returns:
        a copy of the current range
      • stream

        default Stream<N> stream​(UnaryOperator<N> incrementer)
        Return a Stream containing all values contained by the range, with a given incrementer.

        This method should not return the min or max value if they are exclusive.

        The default implementation will apply the incrementer repeatedly on the current value, starting with the min value and will continue as long as contains(Object) returns true.

        Parameters:
        incrementer - the incrementer to use to determine the next value
        Returns:
        a stream containing all values within the range
      • of

        static <N> Range<N> of​(N min,
                               N max,
                               Comparator<? super N> comparator)
      • ofDouble

        static Range<Double> ofDouble​(double min,
                                      double max)
      • ofInteger

        static Range<Integer> ofInteger​(int min,
                                        int max)
      • ofLong

        static Range<Long> ofLong​(long min,
                                  long max)
      • ofClosed

        static <N extends Comparable<N>> Range<N> ofClosed​(N min,
                                                           N max)
      • ofClosed

        static <N> Range<N> ofClosed​(N min,
                                     N max,
                                     Comparator<? super N> comparator)
      • ofDoubleClosed

        static Range<Double> ofDoubleClosed​(double min,
                                            double max)
      • ofIntegerClosed

        static Range<Integer> ofIntegerClosed​(int min,
                                              int max)
      • ofLongClosed

        static Range<Long> ofLongClosed​(long min,
                                        long max)