Class GeneralRange<T>

java.lang.Object
com.google.common.collect.GeneralRange<T>
All Implemented Interfaces:
Serializable

final class GeneralRange<T> extends Object implements 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 Details

    • comparator

      private final Comparator<? super T> comparator
    • hasLowerBound

      private final boolean hasLowerBound
    • lowerEndpoint

      @CheckForNull private final T lowerEndpoint
    • lowerBoundType

      private final BoundType lowerBoundType
    • hasUpperBound

      private final boolean hasUpperBound
    • upperEndpoint

      @CheckForNull private final T upperEndpoint
    • upperBoundType

      private final BoundType upperBoundType
    • reverse

      @CheckForNull private transient GeneralRange<T> reverse
  • Constructor Details

    • GeneralRange

      private GeneralRange(Comparator<? super T> comparator, boolean hasLowerBound, @CheckForNull T lowerEndpoint, BoundType lowerBoundType, boolean hasUpperBound, @CheckForNull T upperEndpoint, BoundType upperBoundType)
  • Method Details

    • from

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

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

      static <T> GeneralRange<T> downTo(Comparator<? super T> comparator, 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(Comparator<? super T> comparator, 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(Comparator<? super T> comparator, T lower, BoundType lowerType, T upper, BoundType upperType)
      Returns everything between the endpoints relative to the specified comparator, with the specified endpoint behavior.
    • comparator

      Comparator<? super T> comparator()
    • hasLowerBound

      boolean hasLowerBound()
    • hasUpperBound

      boolean hasUpperBound()
    • isEmpty

      boolean isEmpty()
    • tooLow

      boolean tooLow(T t)
    • tooHigh

      boolean tooHigh(T t)
    • contains

      boolean contains(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(@CheckForNull Object obj)
      Overrides:
      equals in class Object
    • hashCode

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

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

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

      @CheckForNull T getLowerEndpoint()
    • getLowerBoundType

      BoundType getLowerBoundType()
    • getUpperEndpoint

      @CheckForNull T getUpperEndpoint()
    • getUpperBoundType

      BoundType getUpperBoundType()