de.hpi.fgis.dude.util
Class Pair<T1,T2>

java.lang.Object
  extended by de.hpi.fgis.dude.util.Pair<T1,T2>
Type Parameters:
T1 - The type of the first element.
T2 - The type of the second element.
All Implemented Interfaces:
AutoJsonable
Direct Known Subclasses:
OrderedPair

public class Pair<T1,T2>
extends Object
implements AutoJsonable

A Pair is a container that stores two objects.

Author:
Matthias Pohl

Constructor Summary
Pair()
          Initializes an empty pair.
Pair(T1 first, T2 second)
          Generates a pair of the given two elements.
 
Method Summary
 boolean equals(Object obj)
           
 T1 getFirstElement()
          Returns the first element.
 T2 getSecondElement()
          Returns the second element.
 int hashCode()
           
 boolean isReflexive()
          Checks whether this instance is reflexive.
 boolean isSymmetricTo(Pair<T1,T2> otherPair)
          Checks whether the passed Pair is the symmetric correspondent of this instance.
 void setFirstElement(T1 elem)
          Sets the first element.
 void setSecondElement(T2 elem)
          Sets the second element.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Pair

public Pair()
Initializes an empty pair.


Pair

public Pair(T1 first,
            T2 second)
Generates a pair of the given two elements. The types of both elements are specified by the generic parameters T1 and T2.

Parameters:
first - The first element.
second - The second element.
Throws:
NullPointerException - If at least one of the parameters is null.
Method Detail

getFirstElement

public T1 getFirstElement()
Returns the first element.

Returns:
The first element.

setFirstElement

public void setFirstElement(T1 elem)
Sets the first element.

Parameters:
elem - The new first element.
Throws:
NullPointerException - If null was passed.

getSecondElement

public T2 getSecondElement()
Returns the second element.

Returns:
The second element.

setSecondElement

public void setSecondElement(T2 elem)
Sets the second element.

Parameters:
elem - The new second element.
Throws:
NullPointerException - If null was passed.

equals

public boolean equals(Object obj)
Overrides:
equals in class Object
See Also:
Object.equals(Object)

isSymmetricTo

public boolean isSymmetricTo(Pair<T1,T2> otherPair)
Checks whether the passed Pair is the symmetric correspondent of this instance.

Parameters:
otherPair - A Pair with which the symmetric relation shall be checked.
Returns:
true, if the passed Pair object is the symmetric correspondent of this instance; otherwise false

toString

public String toString()
Overrides:
toString in class Object

isReflexive

public boolean isReflexive()
Checks whether this instance is reflexive.

Returns:
true, if this instance is reflexive; otherwise false.

hashCode

public int hashCode()
Overrides:
hashCode in class Object


Copyright © 2011 Hasso Plattner Institute - Chair of Information Systems. All Rights Reserved.