The objects need to either be implementations of Comparable
or you need to supply a Comparator.
#ThreadSafe# if the objects and comparator are thread-safe.
| Modifier and Type | Class and Description |
|---|---|
| private static enum |
| Modifier and Type | Field and Description |
|---|---|
| private final Comparator | comparator
The ordering scheme used in this range. |
| private transient int | hashCode
Cached output hashCode (class is immutable). |
| private final T | maximum
The maximum value in this range (inclusive). |
| private final T | minimum
The minimum value in this range (inclusive). |
| private static final long | serialVersionUID
Serialization version. |
| private transient String | toString
Cached output toString (class is immutable). |
| Access | Constructor and Description |
|---|---|
| pack-priv | Range(final T
the first element, not null. element1, final T the second element, not null element2, final Comparator<T> the comparator to be used, null for natural ordering. comp)Creates an instance. |
| Modifier and Type | Method and Description |
|---|---|
| public static < the type of the elements in this range. T extends Comparable | Returns: the range object, not null.the first value that defines the edge of the range, inclusive. fromInclusive, final T the second value that defines the edge of the range, inclusive. toInclusive)
Deprecated
Use
of(Comparable, Comparable).
Creates a range with the specified minimum and maximum values (both inclusive). |
| public static < the type of the elements in this range. T> Range | Returns: the range object, not null.the first value that defines the edge of the range, inclusive. fromInclusive, final T the second value that defines the edge of the range, inclusive. toInclusive, final Comparator<T> the comparator to be used, null for natural ordering. comparator)
Deprecated
Use
of(Object, Object, Comparator).
Creates a range with the specified minimum and maximum values (both inclusive). |
| public boolean | Returns: true if the specified element occurs within this range.the element to check for, null returns false. element)Checks whether the specified element occurs within this range. |
| public boolean | Returns: true if this range contains the specified range.the range to check, null returns false. otherRange)Checks whether this range contains all the elements of the specified range. |
| public int | Returns: -1, 0 or +1 depending on the element's location relative to the range.the element to check for, not null. element)Checks where the specified element occurs relative to this range. |
| public boolean | Returns: true if this object is equal.the reference object with which to compare. obj)Overrides java. Compares this range to another object to test if they are equal. |
| public T | Returns: the minimum, the element, or the maximum depending on the element's location relative to the range.the element to check for, not null. element)Fits the given element into this range by returning the given element or, if out of bounds, the range minimum if below, or the range maximum if above. |
| public Comparator | Returns: the comparator being used, not null.Gets the comparator being used to determine if objects are within the range. |
| public T | Returns: the maximum value in this range, not null.Gets the maximum value in this range. |
| public T | Returns: the minimum value in this range, not null.Gets the minimum value in this range. |
| public int | Returns: a hash code value for this object.Overrides java. Gets a suitable hash code for the range. |
| public Range | Returns: range representing the intersection ofthis and other (this if equal).overlapping Range. other)Calculate the intersection of |
| public static < the type of the elements in this range. T extends Comparable | Returns: the range object, not null.the value to use for this range, not null. element)Creates a range using the specified element as both the minimum and maximum in this range. |
| public static < the type of the elements in this range. T> Range | Returns: the range object, not null.the value to use for this range, must not be element, final Comparator<T> null.the comparator to be used, null for natural ordering. comparator)Creates a range using the specified element as both the minimum and maximum in this range. |
| public boolean | Returns: true if this range is entirely after the specified element.the element to check for, null returns false. element)Checks whether this range is after the specified element. |
| public boolean | Returns: true if this range is completely after the specified range.the range to check, null returns false. otherRange)Checks whether this range is completely after the specified range. |
| public boolean | Returns: true if this range is entirely before the specified element.the element to check for, null returns false. element)Checks whether this range is before the specified element. |
| public boolean | Returns: true if this range is completely before the specified range.the range to check, null returns false. otherRange)Checks whether this range is completely before the specified range. |
| public boolean | Returns: true if the specified element occurs within this range.the element to check for, null returns false. element)Checks whether this range ends with the specified element. |
| public boolean | Returns: true if using natural ordering.Tests whether or not the Range is using the natural ordering of the elements. |
| public boolean | Returns: true if the specified range overlaps with this range; otherwise,false.the range to test, null returns false. otherRange)Tests whether this range is overlapped by the specified range. |
| public boolean | Returns: true if the specified element occurs within this range.the element to check for, null returns false. element)Tests whether this range starts with the specified element. |
| public static < the type of the elements in this range. T extends Comparable | Returns: the range object, not null.the first value that defines the edge of the range, inclusive. fromInclusive, final T the second value that defines the edge of the range, inclusive. toInclusive)Creates a range with the specified minimum and maximum values (both inclusive). |
| public static < the type of the elements in this range. T> Range | Returns: the range object, not null.the first value that defines the edge of the range, inclusive. fromInclusive, final T the second value that defines the edge of the range, inclusive. toInclusive, final Comparator<T> the comparator to be used, null for natural ordering. comparator)Creates a range with the specified minimum and maximum values (both inclusive). |
| public String | Returns: theString representation of this range.Overrides java. Gets the range as a |
| public String |
| comparator | back to summary |
|---|---|
| private final Comparator<T> comparator The ordering scheme used in this range. | |
| hashCode | back to summary |
|---|---|
| private transient int hashCode Cached output hashCode (class is immutable). | |
| maximum | back to summary |
|---|---|
| private final T maximum The maximum value in this range (inclusive). | |
| minimum | back to summary |
|---|---|
| private final T minimum The minimum value in this range (inclusive). | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID Serialization version.
| |
| toString | back to summary |
|---|---|
| private transient String toString Cached output toString (class is immutable). | |
| Range | back to summary |
|---|---|
| pack-priv Range(final T element1, final T element2, final Comparator<T> comp) Creates an instance.
| |
| between | back to summary |
|---|---|
| public static <T extends Comparable Deprecated Creates a range with the specified minimum and maximum values (both inclusive). The range uses the natural ordering of the elements to determine where values lie in the range. The arguments may be passed in the order (min,max) or (max,min). The getMinimum and getMaximum methods will return the correct values.
| |
| between | back to summary |
|---|---|
| public static <T> Range Deprecated Creates a range with the specified minimum and maximum values (both inclusive). The range uses the specified The arguments may be passed in the order (min,max) or (max,min). The getMinimum and getMaximum methods will return the correct values.
| |
| contains | back to summary |
|---|---|
| public boolean contains(final T element) Checks whether the specified element occurs within this range.
| |
| containsRange | back to summary |
|---|---|
| public boolean containsRange(final Range<T> otherRange) Checks whether this range contains all the elements of the specified range. This method may fail if the ranges have two different comparators or element types.
| |
| elementCompareTo | back to summary |
|---|---|
| public int elementCompareTo(final T element) Checks where the specified element occurs relative to this range. The API is reminiscent of the Comparable interface returning
| |
| equals | back to summary |
|---|---|
| public boolean equals(final Object obj) Overrides java. Compares this range to another object to test if they are equal. To be equal, the minimum and maximum values must be equal, which ignores any differences in the comparator. | |
| fit | back to summary |
|---|---|
| public T fit(final T element) Fits the given element into this range by returning the given element or, if out of bounds, the range minimum if below, or the range maximum if above.
| |
| getComparator | back to summary |
|---|---|
| public Comparator Gets the comparator being used to determine if objects are within the range. Natural ordering uses an internal comparator implementation, thus this
method never returns null. See
| |
| getMaximum | back to summary |
|---|---|
| public T getMaximum() Gets the maximum value in this range.
| |
| getMinimum | back to summary |
|---|---|
| public T getMinimum() Gets the minimum value in this range.
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Gets a suitable hash code for the range.
| |
| intersectionWith | back to summary |
|---|---|
| public Range Calculate the intersection of
| |
| is | back to summary |
|---|---|
| public static <T extends Comparable Creates a range using the specified element as both the minimum and maximum in this range. The range uses the natural ordering of the elements to determine where values lie in the range.
| |
| is | back to summary |
|---|---|
| public static <T> Range Creates a range using the specified element as both the minimum and maximum in this range. The range uses the specified
| |
| isAfter | back to summary |
|---|---|
| public boolean isAfter(final T element) Checks whether this range is after the specified element.
| |
| isAfterRange | back to summary |
|---|---|
| public boolean isAfterRange(final Range<T> otherRange) Checks whether this range is completely after the specified range. This method may fail if the ranges have two different comparators or element types.
| |
| isBefore | back to summary |
|---|---|
| public boolean isBefore(final T element) Checks whether this range is before the specified element.
| |
| isBeforeRange | back to summary |
|---|---|
| public boolean isBeforeRange(final Range<T> otherRange) Checks whether this range is completely before the specified range. This method may fail if the ranges have two different comparators or element types.
| |
| isEndedBy | back to summary |
|---|---|
| public boolean isEndedBy(final T element) Checks whether this range ends with the specified element.
| |
| isNaturalOrdering | back to summary |
|---|---|
| public boolean isNaturalOrdering() Tests whether or not the Range is using the natural ordering of the elements. Natural ordering uses an internal comparator implementation, thus this method is the only way to check if a null comparator was specified.
| |
| isOverlappedBy | back to summary |
|---|---|
| public boolean isOverlappedBy(final Range<T> otherRange) Tests whether this range is overlapped by the specified range. Two ranges overlap if there is at least one element in common. This method may fail if the ranges have two different comparators or element types.
| |
| isStartedBy | back to summary |
|---|---|
| public boolean isStartedBy(final T element) Tests whether this range starts with the specified element.
| |
| of | back to summary |
|---|---|
| public static <T extends Comparable Creates a range with the specified minimum and maximum values (both inclusive). The range uses the natural ordering of the elements to determine where values lie in the range. The arguments may be passed in the order (min,max) or (max,min). The getMinimum and getMaximum methods will return the correct values.
| |
| of | back to summary |
|---|---|
| public static <T> Range Creates a range with the specified minimum and maximum values (both inclusive). The range uses the specified The arguments may be passed in the order (min,max) or (max,min). The getMinimum and getMaximum methods will return the correct values.
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Gets the range as a The format of the String is '[min..max]'. | |
| toString | back to summary |
|---|---|
| public String toString(final String format) Formats the receiver using the given format. This uses | |
| Modifier and Type | Field and Description |
|---|---|
| public static final Range. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public int | Returns: negative, 0, positive comparison value.left-hand side side of comparison. obj1, final Object right-hand side side of comparison. obj2)Implements java. Comparable based compare implementation. |
| public static Range. | |
| public static Range. |
| INSTANCE | back to summary |
|---|---|
| public static final Range. | |
| ComparableComparator | back to summary |
|---|---|
| private ComparableComparator() | |
| compare | back to summary |
|---|---|
| public int compare(final Object obj1, final Object obj2) Implements java. Comparable based compare implementation. | |
| valueOf | back to summary |
|---|---|
| public static Range. | |
| values | back to summary |
|---|---|
| public static Range. | |