com.groiss.ds
Class Pair<F,S>

java.lang.Object
  extended by com.groiss.ds.Pair<F,S>
All Implemented Interfaces:
KeyValuePair<F,S>, java.io.Serializable
Direct Known Subclasses:
ComparablePair

public class Pair<F,S>
extends java.lang.Object
implements KeyValuePair<F,S>, java.io.Serializable

A Pair is an object that contains two other objects. It is most commonly used for conveniently storing and passing pairs of objects.

See Also:
Serialized Form

Field Summary
 F first
          The first object.
 S second
          The second object.
 
Constructor Summary
Pair()
           
Pair(F first, S second)
          Constructor for holding a pair of objects.
 
Method Summary
 boolean equals(java.lang.Object obj)
          Returns true if obj is also a Pair and contains two objects equal to the two objects of this Pair.
 F getKey()
          Return the first object
 S getValue()
          Return the second object
 int hashCode()
          Builds a new hash code out of the two objects' hash codes.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

first

public F first
The first object.


second

public S second
The second object.

Constructor Detail

Pair

public Pair()

Pair

public Pair(F first,
            S second)
Constructor for holding a pair of objects.

Method Detail

getKey

public F getKey()
Return the first object

Specified by:
getKey in interface KeyValuePair<F,S>

getValue

public S getValue()
Return the second object

Specified by:
getValue in interface KeyValuePair<F,S>

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Returns true if obj is also a Pair and contains two objects equal to the two objects of this Pair. null references are considered as equal, too.

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Builds a new hash code out of the two objects' hash codes.

Overrides:
hashCode in class java.lang.Object


@enterprise 8.0.22989 Copyright © 2001-2017 Groiss Informatics GmbH. All Rights Reserved.