View Javadoc

1   /*
2    * Created on Feb 6, 2005
3    *
4    * TODO To change the template for this generated file go to
5    * Window - Preferences - Java - Code Style - Code Templates
6    */
7   package net.sf.bddbddb.order;
8   
9   import jwutil.collections.Pair;
10  
11  /***
12   * @author mcarbin
13   *
14   * TODO To change the template for this generated type comment go to
15   * Window - Preferences - Java - Code Style - Code Templates
16   */
17  public class UnorderedPair extends Pair {
18      
19      /***
20       * Version ID for serialization.
21       */
22      private static final long serialVersionUID = 3258135756147798328L;
23      
24      /***
25       * @param left
26       * @param right
27       */
28      public UnorderedPair(Object left, Object right) {
29          super(left, right);
30      }
31      
32      
33      /* (non-Javadoc)
34       * @see java.lang.Object#equals(java.lang.Object)
35       */
36      public boolean equals(Object o) {
37         if(o instanceof UnorderedPair){
38             UnorderedPair that = (UnorderedPair) o;
39             return (this.left.equals(that.left) && this.right.equals(that.right)) ||
40                    (this.left.equals(that.right) & this.right.equals(that.left));
41         }
42         return false;
43      }
44      /***
45       * Returns the hash code value for this set.  The hash code of a set is
46       * defined to be the sum of the hash codes of the elements in the set.
47       * This ensures that <tt>s1.equals(s2)</tt> implies that
48       * <tt>s1.hashCode()==s2.hashCode()</tt> for any two sets <tt>s1</tt>
49       * and <tt>s2</tt>, as required by the general contract of
50       * Object.hashCode.<p>
51       *
52       * This implementation enumerates over the set, calling the
53       * <tt>hashCode</tt> method on each element in the collection, and
54       * adding up the results.
55       *
56       * @return the hash code value for this set.
57       */
58      public int hashCode() {
59          return left.hashCode() + right.hashCode();
60      }
61  
62  }