TUM CCSM Commons

edu.tum.cs.commons.collections
Class ImmutablePair<S,T>

java.lang.Object
  extended by edu.tum.cs.commons.collections.ImmutablePair<S,T>
All Implemented Interfaces:
IDeepCloneable, java.lang.Cloneable, java.lang.Comparable<ImmutablePair<S,T>>
Direct Known Subclasses:
Pair

public class ImmutablePair<S,T>
extends java.lang.Object
implements java.lang.Cloneable, IDeepCloneable, java.lang.Comparable<ImmutablePair<S,T>>

Simple readonly pair class.

Version:
$Rev: 26268 $
Author:
hummelb, $Author: juergens $
Rating:
GREEN Hash: 8C6F4981DA02F9D8D8CFF01534F52D67

Field Summary
protected  S first
          The first element.
protected  T second
          The second element.
 
Constructor Summary
ImmutablePair(ImmutablePair<S,T> p)
          Copy constructor.
ImmutablePair(S first, T second)
          Constructor.
 
Method Summary
protected  ImmutablePair<S,T> clone()
          
 int compareTo(ImmutablePair<S,T> pair)
           Compare based on first element.
 ImmutablePair<S,T> deepClone()
          Deep clone of this object.
 boolean equals(java.lang.Object obj)
          
 S getFirst()
          Returns the first element of the pair.
 T getSecond()
          Returns the second element of the pair.
 int hashCode()
           The hash code is based on the hash code of the first and second members.
 java.lang.String toString()
          
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

first

protected S first
The first element.


second

protected T second
The second element.

Constructor Detail

ImmutablePair

public ImmutablePair(S first,
                     T second)
Constructor.


ImmutablePair

public ImmutablePair(ImmutablePair<S,T> p)
Copy constructor.

Method Detail

getFirst

public S getFirst()
Returns the first element of the pair.


getSecond

public T getSecond()
Returns the second element of the pair.


equals

public boolean equals(java.lang.Object obj)

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()

The hash code is based on the hash code of the first and second members.

Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object

clone

protected ImmutablePair<S,T> clone()

Overrides:
clone in class java.lang.Object

deepClone

public ImmutablePair<S,T> deepClone()
                             throws DeepCloneException
Deep clone of this object.

Specified by:
deepClone in interface IDeepCloneable
Throws:
DeepCloneException - if problems during cloning occured.

compareTo

public int compareTo(ImmutablePair<S,T> pair)

Compare based on first element. Use second element only if first elements are equal. Null entries are sorted to the top.

Specified by:
compareTo in interface java.lang.Comparable<ImmutablePair<S,T>>

TUM CCSM Commons

TUM CCSM Commons - 2.7