1 46 package org.jaxen.expr; 47 48 import java.util.HashSet ; 49 50 51 59 final class IdentitySet { 60 61 private HashSet contents = new HashSet (); 62 63 IdentitySet() { 64 super(); 65 } 66 67 void add(Object object) { 68 IdentityWrapper wrapper = new IdentityWrapper(object); 69 contents.add(wrapper); 70 } 71 72 public boolean contains(Object object) { 73 IdentityWrapper wrapper = new IdentityWrapper(object); 74 return contents.contains(wrapper); 75 } 76 77 private static class IdentityWrapper { 78 79 private Object object; 80 81 IdentityWrapper(Object object) { 82 this.object = object; 83 } 84 85 public boolean equals(Object o) { 86 IdentityWrapper w = (IdentityWrapper) o; 87 return object == w.object; 88 } 89 90 public int hashCode() { 91 return System.identityHashCode(object); 92 } 93 94 } 95 96 97 } 98 | Popular Tags |