public final class BasicIntInterval extends java.lang.Object implements IntInterval, java.lang.Comparable<BasicIntInterval>
Class BasicIntInterval
represents an interval of
consecutive integers.
BasicIntInterval
are immutable.Constructor and Description |
---|
BasicIntInterval(int start,
int end)
Constructs an
SimpleIntInterval instance. |
Modifier and Type | Method and Description |
---|---|
int |
compareTo(BasicIntInterval o)
Compares the specified
BasicIntInterval with this for order,
and returns a negative integer, zero, or a positive integer as
this is less than, equal to, or greater than the specified
BasicIntInterval object. |
int |
end()
Returns the end of the interval (inclusive).
|
boolean |
equals(java.lang.Object obj)
Returns
true if the specified object is an
BasicIntInterval instance and
this.start() == ((BasicIntInterval) obj).start() , and
this.end() == ((BasicIntInterval) obj).end() ,
and returns false otherwise. |
int |
hashCode()
Returns a hash code value for the object.
|
int |
start()
Returns the start of the interval (inclusive).
|
java.lang.String |
toString()
Returns a string representation of
this . |
public BasicIntInterval(int start, int end)
SimpleIntInterval
instance.start
- the starting integer (inclusive).end
- the ending integer (inclusive).java.lang.IllegalArgumentException
- if start>end
.public int start()
IntInterval
start
in interface IntInterval
public int end()
IntInterval
end
in interface IntInterval
public int hashCode()
Returns a hash code value for the object.
The hash code is defined by the following calculation:
int hash = 3; hash += 59 * hash + this.start(); hash += 59 * hash + this.end();
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
true
if the specified object is an
BasicIntInterval
instance and
this.start() == ((BasicIntInterval) obj).start()
, and
this.end() == ((BasicIntInterval) obj).end()
,
and returns false
otherwise.equals
in class java.lang.Object
obj
- the object to be compared with this
for equality.true
if the specified object is equal to
this
, and returns false otherwise.public int compareTo(BasicIntInterval o)
BasicIntInterval
with this for order,
and returns a negative integer, zero, or a positive integer as
this
is less than, equal to, or greater than the specified
BasicIntInterval
object.
BasicIntInterval
objects are
ordered by their start and their end values in that order.compareTo
in interface java.lang.Comparable<BasicIntInterval>
o
- the BasicIntInterval
to be compared with this.public java.lang.String toString()
this
. The exact
details of the representation are unspecified and subject to change.toString
in class java.lang.Object
this
. The exact
details of the representation are unspecified and subject to change.