Class GeneralRange<T>

  • All Implemented Interfaces:
    java.io.Serializable

    @GwtCompatible(serializable=true)
    final class GeneralRange<T>
    extends java.lang.Object
    implements java.io.Serializable
    A generalized interval on any ordering, for internal use. Supports null. Unlike Range, this allows the use of an arbitrary comparator. This is designed for use in the implementation of subcollections of sorted collection types.

    Whenever possible, use Range instead, which is better supported.

    • Field Detail

      • comparator

        private final java.util.Comparator<? super T> comparator
      • hasLowerBound

        private final boolean hasLowerBound
      • lowerEndpoint

        @Nullable
        private final T lowerEndpoint
      • lowerBoundType

        private final BoundType lowerBoundType
      • hasUpperBound

        private final boolean hasUpperBound
      • upperEndpoint

        @Nullable
        private final T upperEndpoint
      • upperBoundType

        private final BoundType upperBoundType
    • Constructor Detail

      • GeneralRange

        private GeneralRange​(java.util.Comparator<? super T> comparator,
                             boolean hasLowerBound,
                             @Nullable
                             T lowerEndpoint,
                             BoundType lowerBoundType,
                             boolean hasUpperBound,
                             @Nullable
                             T upperEndpoint,
                             BoundType upperBoundType)
    • Method Detail

      • from

        static <T extends java.lang.Comparable> GeneralRange<T> from​(Range<T> range)
        Converts a Range to a GeneralRange.
      • all

        static <T> GeneralRange<T> all​(java.util.Comparator<? super T> comparator)
        Returns the whole range relative to the specified comparator.
      • downTo

        static <T> GeneralRange<T> downTo​(java.util.Comparator<? super T> comparator,
                                          @Nullable
                                          T endpoint,
                                          BoundType boundType)
        Returns everything above the endpoint relative to the specified comparator, with the specified endpoint behavior.
      • upTo

        static <T> GeneralRange<T> upTo​(java.util.Comparator<? super T> comparator,
                                        @Nullable
                                        T endpoint,
                                        BoundType boundType)
        Returns everything below the endpoint relative to the specified comparator, with the specified endpoint behavior.
      • range

        static <T> GeneralRange<T> range​(java.util.Comparator<? super T> comparator,
                                         @Nullable
                                         T lower,
                                         BoundType lowerType,
                                         @Nullable
                                         T upper,
                                         BoundType upperType)
        Returns everything between the endpoints relative to the specified comparator, with the specified endpoint behavior.
      • comparator

        java.util.Comparator<? super T> comparator()
      • hasLowerBound

        boolean hasLowerBound()
      • hasUpperBound

        boolean hasUpperBound()
      • isEmpty

        boolean isEmpty()
      • tooLow

        boolean tooLow​(@Nullable
                       T t)
      • tooHigh

        boolean tooHigh​(@Nullable
                        T t)
      • contains

        boolean contains​(@Nullable
                         T t)
      • intersect

        GeneralRange<T> intersect​(GeneralRange<T> other)
        Returns the intersection of the two ranges, or an empty range if their intersection is empty.
      • equals

        public boolean equals​(@Nullable
                              java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • reverse

        GeneralRange<T> reverse()
        Returns the same range relative to the reversed comparator.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • getLowerEndpoint

        T getLowerEndpoint()
      • getLowerBoundType

        BoundType getLowerBoundType()
      • getUpperEndpoint

        T getUpperEndpoint()
      • getUpperBoundType

        BoundType getUpperBoundType()