|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.ivmaidns.util.ConstPair
public final class ConstPair
Class for immutable pairs of objects. This instantable class is useful for representation of a constant sortable pair of custom objects of any type (a container for two elements).
ConstVector
,
GComparator
,
Serialized FormField Summary | |
---|---|
protected java.lang.Object |
valueA
The first custom object of this pair. |
protected java.lang.Object |
valueB
The second custom object of this pair. |
Constructor Summary | |
---|---|
ConstPair(java.lang.Object valueA,
java.lang.Object valueB)
Constructs an immutable 'pair' container. |
Method Summary | |
---|---|
java.lang.Object |
clone()
Creates and returns a copy of this object. |
boolean |
equals(java.lang.Object obj)
Indicates whether this object is equal to the
specified one. |
java.lang.Object |
getAt(int index)
Returns value of the element at the specified index. |
boolean |
greaterThan(java.lang.Object obj)
Tests for being semantically greater than the argument. |
int |
hashCode()
Computes and returns a hash code value for the object. |
int |
length()
Returns the number of elements in this container. |
java.lang.String |
toString()
Converts container to its 'in-line' string representation. |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected final java.lang.Object valueA
this
pair.
ConstPair(java.lang.Object, java.lang.Object)
,
getAt(int)
protected final java.lang.Object valueB
this
pair.
ConstPair(java.lang.Object, java.lang.Object)
,
getAt(int)
Constructor Detail |
---|
public ConstPair(java.lang.Object valueA, java.lang.Object valueB)
valueA
- the first custom object (may be null
).valueB
- the second custom object (may be null
).getAt(int)
,
equals(java.lang.Object)
,
greaterThan(java.lang.Object)
,
toString()
Method Detail |
---|
public int length()
this
container.
Here, the result is 2.
length
in interface Indexable
getAt(int)
public java.lang.Object getAt(int index) throws java.lang.ArrayIndexOutOfBoundsException
getAt
in interface Indexable
index
- the index (must be in the range) at which to return an element.
null
) at index.
java.lang.ArrayIndexOutOfBoundsException
- if index is negative or is not less than
length()
.ConstPair(java.lang.Object, java.lang.Object)
,
length()
public java.lang.Object clone()
this
object.
The result is the same as of
new ConstPair(getAt(0), getAt(1))
.
clone
in interface ReallyCloneable
clone
in class java.lang.Object
null
and != this
) of
this
instance.
java.lang.OutOfMemoryError
- if there is not enough memory.ConstPair(java.lang.Object, java.lang.Object)
,
getAt(int)
,
equals(java.lang.Object)
public int hashCode()
null
elements of
this
container and mixes them all to produce a
single hash code value.
hashCode
in class java.lang.Object
this
object.length()
,
getAt(int)
,
equals(java.lang.Object)
public boolean equals(java.lang.Object obj)
this
object is equal to the
specified one.
This method returns true
if and only if
obj is instance of this container class and all
elements of this
container are equal to the
corresponding elements of obj.
equals
in class java.lang.Object
obj
- the object (may be null
) with which to compare.
true
if and only if this
value is the
same as obj value.ConstPair(java.lang.Object, java.lang.Object)
,
length()
,
getAt(int)
,
hashCode()
,
greaterThan(java.lang.Object)
public boolean greaterThan(java.lang.Object obj)
true
if and only if obj is
instance of this
class and this
object
is greater than the specified object. Containers are compared in
the element-by-element manner, starting at index 0
.
So, the first elements pair is tested for equality and then it
(if equality test has failed) or (else) the second elements pair
is compared through INSTANCE
of
GComparator
class (and the result of this comparison
is returned).
greaterThan
in interface Sortable
obj
- the second compared object (may be null
).
true
if obj is comparable with
this
and this
object is greater than
obj, else false
.length()
,
getAt(int)
,
equals(java.lang.Object)
public java.lang.String toString()
toString
in class java.lang.Object
null
, with non-zero
length()
) of this
object.
java.lang.OutOfMemoryError
- if there is not enough memory.ConstPair(java.lang.Object, java.lang.Object)
,
length()
,
getAt(int)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |