us.zuercher.gpx2map.util
Class Pair<A,B>

java.lang.Object
  extended by us.zuercher.gpx2map.util.Pair<A,B>

public class Pair<A,B>
extends Object

Pair provides a simple way to associate two objects together.

Author:
Stephan Zuercher

Field Summary
 A first
          First item of the pair.
 B second
          Second item of the pair.
 
Constructor Summary
Pair(A first, B second)
          Constructs a new Pair with the given items.
 
Method Summary
 boolean equals(Object that)
          Compares two Pairs to for equality.
 boolean equals(Pair<A,B> that)
          Compares two Pairs to for equality.
 boolean firstsEqual(Pair<A,B> that)
          Tests if both firsts of this and that Pair are equal.
 A getFirst()
          Returns the first item of the pair.
 B getSecond()
          Returns the second item of the pair.
 boolean secondsEqual(Pair<A,B> that)
          Tests if both seconds of this and that Pair are equal.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

first

public final A first
First item of the pair.


second

public final B second
Second item of the pair.

Constructor Detail

Pair

public Pair(A first,
            B second)
Constructs a new Pair with the given items.

Parameters:
first - first item of the pair
second - second item of the pair
Method Detail

getFirst

public A getFirst()
Returns the first item of the pair.

Returns:
the first item of the pair.

getSecond

public B getSecond()
Returns the second item of the pair.

Returns:
the second item of the pair.

equals

public boolean equals(Object that)
Compares two Pairs to for equality. They are both equal if both first items are equal and both second items are equal. Equality for the firsts is defined as both firsts null or both firsts non-null and equal via Object.equals(Object). The same applies for the seconds.

Overrides:
equals in class Object
Parameters:
that - another Pair
Returns:
true if the Pairs are equal
Throws:
ClassCastException - if other is not a Pair

equals

public boolean equals(Pair<A,B> that)
Compares two Pairs to for equality. They are both equal if both first items are equal and both second items are equal. Equality for the firsts is defined as both firsts null or both firsts non-null and equal via Object.equals(Object). The same applies for the seconds.

Parameters:
that - another Pair
Returns:
true if the Pairs are equal

firstsEqual

public boolean firstsEqual(Pair<A,B> that)
Tests if both firsts of this and that Pair are equal. Equality is defined as both null or both non-null and equal by Object.equals(Object).

Parameters:
that - another Pair
Returns:
true if the Pairs have equal firsts.

secondsEqual

public boolean secondsEqual(Pair<A,B> that)
Tests if both seconds of this and that Pair are equal. Equality is defined as both null or both non-null and equal by Object.equals(Object).

Parameters:
that - another Pair
Returns:
true if the Pairs have equal seconds.