1 package dynaop.example; 2 3 import java.io.Serializable ; 4 5 import dynaop.Proxy; 6 import dynaop.ProxyAware; 7 8 14 public class IdentifiableMixin implements Identifiable, ProxyAware, 15 Serializable { 16 17 Object proxy; 18 19 private long id = -1; 20 21 public long getId() { 22 return this.id; 23 } 24 25 public void setId(long id) { 26 this.id = id; 27 } 28 29 public boolean equals(Object o) { 30 if (!(o instanceof Identifiable)) 32 return false; 33 34 if (!proxy.getClass().equals(o.getClass())) 36 return false; 37 38 return ((Identifiable) o).getId() == getId(); 40 } 41 42 public int hashCode() { 43 return this.proxy.getClass().hashCode() * 31 + (int) getId(); 44 } 45 46 public void setProxy(Proxy proxy) { 47 this.proxy = proxy; 48 } 49 } | Popular Tags |