1 package net.sf.openrocket.util;
4 * Storage for a pair of objects.
6 * @author Sampo Niskanen <sampo.niskanen@iki.fi>
7 * @param <U> the first object type.
8 * @param <V> the second object type.
10 public class Pair<U,V> {
16 public Pair(U u, V v) {
31 * Compare both components of the Pair to another object.
32 * The pair is equal iff both items are equal (or null).
34 @SuppressWarnings("unchecked")
36 public boolean equals(Object other) {
37 if (!(other instanceof Pair))
39 Object otherU = ((Pair)other).getU();
40 Object otherV = ((Pair)other).getV();
46 if (!otherU.equals(this.u))
54 if (!otherV.equals(this.v))
61 public int hashCode() {
62 return ((u != null) ? u.hashCode() : 0) + ((v != null) ? v.hashCode() : 0);
67 public String toString() {
68 return "[" + u + ";" + v + "]";