hudson.plugins.im.tools
Class Pair<H,T>

java.lang.Object
  extended by hudson.plugins.im.tools.Pair<H,T>
Type Parameters:
H - Type of the head
T - Type of the tail

public final class Pair<H,T>
extends java.lang.Object

Pair is a helper class for the frequent case, when two objects must be combined for a collection entry or even a key. The concept of a pair is fundamental for all languages derived from LISP and is even useful in a language like Java.

Note: Pairs may be used as keys for a hash collection, when both elements, named head and tail, implements the hashing protocol.


Constructor Summary
Pair(H head, T tail)
          Constructs a Pair using the two given objects as head and tail.
 
Method Summary
static
<H2,T2> Pair<H2,T2>
create(H2 head, T2 tail)
           
 boolean equals(java.lang.Object other)
          
 H getHead()
          Returns the head object of the pair.
 T getTail()
          Returns the tail object of the pair.
 int hashCode()
          
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Pair

public Pair(H head,
            T tail)
Constructs a Pair using the two given objects as head and tail.

Parameters:
head - the object to be used as the head of the pair
tail - the object to be used as the tail of the pair
Method Detail

create

public static <H2,T2> Pair<H2,T2> create(H2 head,
                                         T2 tail)

getHead

public H getHead()
Returns the head object of the pair.

Returns:
the head object of the pair
See Also:
getTail()

getTail

public T getTail()
Returns the tail object of the pair.

Returns:
the tail object of the pair
See Also:
getHead()

equals

public boolean equals(java.lang.Object other)

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()

Overrides:
hashCode in class java.lang.Object


Copyright © 2010. All Rights Reserved.