1 4 package org.oddjob.arooa.registry; 5 6 import java.io.ObjectStreamException ; 7 import java.io.Serializable ; 8 9 15 public class ServerId implements Serializable { 16 private static final long serialVersionUID= 20051117; 17 18 19 private static final ServerId local = new ServerId("local"); 20 21 22 private final String serverId; 23 24 29 public ServerId(String serverId) { 30 if (serverId == null) { 31 throw new NullPointerException ("Server Id must not be null."); 32 } 33 this.serverId = serverId; 34 } 35 36 40 public String toString() { 41 return serverId; 42 } 43 44 48 public boolean equals(Object o) { 49 if (!(o instanceof ServerId)) { 50 return false; 51 } 52 ServerId other = (ServerId) o; 53 if (other == local) { 54 return this == local; 55 } 56 if (this == local) { 57 return other == local; 58 } 59 return this.serverId.equals(other.serverId); 60 61 } 62 63 67 public int hashCode() { 68 return serverId.hashCode(); 69 } 70 71 76 public static ServerId local() { 77 return local; 78 } 79 80 private Object readResolve() throws ObjectStreamException { 81 if (serverId.equals(local.serverId)) { 82 return local; 83 } 84 else { 85 return this; 86 } 87 } 88 89 } 90 | Popular Tags |