001 package hep.aida.ref.sql;
002
003 /** <code>Pair</code> is a pair of objects.
004 * <p><font color="#880088">
005 * <pre>
006 * $Log: Pair.java,v $
007 * Revision 1.7 2007/05/23 16:38:44 hrivnac
008 * logical connections for Plotter; better UML
009 *
010 * Revision 1.6 2006/04/22 12:34:17 hrivnac
011 * Web Service included
012 *
013 * Revision 1.5 2004/05/22 15:12:59 hrivnac
014 * class id reformated
015 *
016 * Revision 1.4 2004/04/14 13:39:46 hrivnac
017 * 1.5 warnings fixed
018 *
019 * Revision 1.3 2004/02/10 14:50:58 hrivnac
020 * JavaDoc tags completed
021 *../../SQLTuple/src/hep/aida/ref/sql/Utilities
022 * Revision 1.2 2004/02/09 15:29:39 hrivnac
023 * better hashcode
024 *
025 * Revision 1.1 2004/02/04 13:30:39 hrivnac
026 * - improvement of Enums internal mapping
027 * - general cleaning
028 *
029 * </pre>
030 * </font></p>
031 * @opt attributes
032 * @opt operations
033 * @opt types
034 * @opt visibility
035 * @version $Id: Pair.java,v 1.7 2007/05/23 16:38:44 hrivnac Exp $
036 * @author <a href="mailto:Julius.Hrivnac@cern.ch">J.Hrivnac</a> */
037 public class Pair<A, B> {
038
039 public A first;
040
041 public B second;
042
043 /** Create a pair of Objects of types A and B.
044 * @param a The first Object.
045 * @param b The second Objec. */
046 public Pair(A a, B b) {
047 first = a;
048 second = b;
049 }
050
051 public boolean equals(Object o) {
052 return o instanceof Pair &&
053 first.equals(((Pair)o).first) &&
054 second.equals(((Pair)o).second) &&
055 hashCode() == o.hashCode();
056 }
057
058 public int hashCode() {
059 return 31 * first.hashCode() + second.hashCode();
060 }
061
062 public String toString() {
063 return "Pair<" + first.getClass().getName() + ", " + second.getClass().getName() + ">" +
064 " = {" + first.toString() + ", " + second.toString() + "}";
065 }
066
067 }