java.lang.Object | |
↳ | android.util.Range<T extends java.lang.Comparable<? super T>> |
Immutable class for describing the range of two numeric values.
A range (or "interval") defines the inclusive boundaries around a contiguous span of
values of some Comparable
type; for example,
"integers from 1 to 100 inclusive."
All ranges are bounded, and the left side of the range is always >=
the right side of the range.
Although the implementation itself is immutable, there is no restriction that objects stored must also be immutable. If mutable objects are stored here, then the range effectively becomes mutable.
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Create a new immutable range.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Create a new immutable range, with the argument types inferred.
| |||||||||||
Compare two ranges for equality.
| |||||||||||
Get the lower endpoint.
| |||||||||||
Get the upper endpoint.
| |||||||||||
Returns an integer hash code for this object.
| |||||||||||
Checks if the
value is within the bounds of this range. | |||||||||||
Return the range as a string representation
"[lower, upper]" . |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
Create a new immutable range.
The endpoints are [lower, upper]
; that
is the range is bounded. lower
must be lesser or equal
to upper
.
lower | The lower endpoint (inclusive) |
---|---|
upper | The upper endpoint (inclusive) |
NullPointerException | if lower or upper is null
|
---|
Create a new immutable range, with the argument types inferred.
The endpoints are [lower, upper]
; that
is the range is bounded. lower
must be lesser or equal
to upper
.
lower | The lower endpoint (inclusive) |
---|---|
upper | The upper endpoint (inclusive) |
NullPointerException | if lower or upper is null
|
---|
Compare two ranges for equality.
A range is considered equal if and only if both the lower and upper endpoints are also equal.
obj | the object to compare this instance with. |
---|
true
if the ranges are equal, false
otherwise
Get the lower endpoint.
null
T
reference
Get the upper endpoint.
null
T
reference
Returns an integer hash code for this object. By contract, any two
objects for which equals(Object)
returns true
must return
the same hash code value. This means that subclasses of Object
usually override both methods or neither method.
Note that hash values must not change over time unless information used in equals comparisons also changes.
See Writing a correct
hashCode
method
if you intend implementing your own hashCode
method.
Checks if the value
is within the bounds of this range.
A value is considered to be within this range if it's >=
then
the lower endpoint and <=
to the upper endpoint (using the Comparable
interface.
value | a non-null T reference |
---|
true
if the value is within this inclusive range, false
otherwiseNullPointerException | if value was null
|
---|
Return the range as a string representation "[lower, upper]"
.