Class NumberRange<N extends Number>
java.lang.Object
org.apache.commons.lang3.Range<N>
org.apache.commons.lang3.NumberRange<N>
- Type Parameters:
N- The Number class.
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
DoubleRange, IntegerRange, LongRange
-
Constructor Summary
Constructors -
Method Summary
Methods inherited from class Range
between, between, contains, containsRange, elementCompareTo, equals, fit, getComparator, getMaximum, getMinimum, hashCode, intersectionWith, is, is, isAfter, isAfterRange, isBefore, isBeforeRange, isEndedBy, isNaturalOrdering, isOverlappedBy, isStartedBy, of, of, toString, toStringModifier and TypeMethodDescriptionstatic <T extends Comparable<? super T>>
Range<T> between(T fromInclusive, T toInclusive) Deprecated.static <T> Range<T> between(T fromInclusive, T toInclusive, Comparator<T> comparator) Deprecated.booleanChecks whether the specified element occurs within this range.booleancontainsRange(Range<N> otherRange) Checks whether this range contains all the elements of the specified range.intelementCompareTo(N element) Checks where the specified element occurs relative to this range.booleanCompares this range to another object to test if they are equal.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.Gets the comparator being used to determine if objects are within the range.Gets the maximum value in this range.Gets the minimum value in this range.inthashCode()Gets a suitable hash code for the range.intersectionWith(Range<N> other) Calculate the intersection ofthisand an overlapping Range.static <T extends Comparable<? super T>>
Range<T> is(T element) Creates a range using the specified element as both the minimum and maximum in this range.static <T> Range<T> is(T element, Comparator<T> comparator) Creates a range using the specified element as both the minimum and maximum in this range.booleanTests whether this range is after the specified element.booleanisAfterRange(Range<N> otherRange) Tests whether this range is completely after the specified range.booleanTests whether this range is before the specified element.booleanisBeforeRange(Range<N> otherRange) Tests whether this range is completely before the specified range.booleanTests whether this range ends with the specified element.booleanTests whether or not the Range is using the natural ordering of the elements.booleanisOverlappedBy(Range<N> otherRange) Tests whether this range is overlapped by the specified range.booleanisStartedBy(N element) Tests whether this range starts with the specified element.static <T extends Comparable<? super T>>
Range<T> of(T fromInclusive, T toInclusive) Creates a range with the specified minimum and maximum values (both inclusive).static <T> Range<T> of(T fromInclusive, T toInclusive, Comparator<T> comparator) Creates a range with the specified minimum and maximum values (both inclusive).toString()Gets the range as aString.Formats the receiver using the given format.
-
Constructor Details
-
NumberRange
Creates an instance.- Parameters:
number1- The first element, not null.number2- The second element, not null.comp- The comparator to be used, null for natural ordering.- Throws:
NullPointerException- Thrown when element1 is null.NullPointerException- Thrown when element2 is null.IllegalArgumentException- Thrown when element1 or element2 is a floating-point NaN.
-
Range.of(Comparable, Comparable).