View Javadoc

1   // IdentityHashCodeWrapper.java, created Wed Mar  5  0:26:27 2003 by joewhaley
2   // Copyright (C) 2001-3 John Whaley <jwhaley@alum.mit.edu>
3   // Licensed under the terms of the GNU LGPL; see COPYING for details.
4   package jwutil.collections;
5   
6   import jwutil.util.Assert;
7   
8   /*
9    * @author  John Whaley <jwhaley@alum.mit.edu>
10   * @version $Id: IdentityHashCodeWrapper.java 1934 2004-09-27 22:42:35Z joewhaley $
11   */
12  public class IdentityHashCodeWrapper {
13      
14      private Object o;
15      private IdentityHashCodeWrapper(Object o) {
16          this.o = o;
17      }
18      public static IdentityHashCodeWrapper create(Object o) {
19          Assert._assert(o != null);
20          return new IdentityHashCodeWrapper(o);
21      }
22      public boolean equals(Object that) {
23          if (this == that) return true;
24          if (!(that instanceof IdentityHashCodeWrapper)) return false;
25          return this.o == ((IdentityHashCodeWrapper)that).o;
26      }
27      public int hashCode() {
28          return System.identityHashCode(o);
29      }
30      
31      public Object getObject() { return o; }
32      
33  }