1 6 7 package org.jfox.ioc.util; 8 9 import java.io.Serializable ; 10 11 14 15 public class ObjectUUID implements Serializable { 16 17 private VMID vmid = VMID.getInstance(); 18 private UUID uuid = UUID.randomUUID(); 19 20 private ObjectUUID() { 21 22 } 23 24 public static ObjectUUID randomUUID() { 25 return new ObjectUUID(); 26 } 27 28 public VMID getVMID() { 29 return vmid; 30 } 31 32 public UUID getUUID() { 33 return uuid; 34 } 35 36 public String toString() { 37 return vmid.toString() + "-" + uuid.toString(); 38 } 39 40 public boolean equals(Object o) { 41 if(this == o) return true; 42 if(!(o instanceof ObjectUUID)) return false; 43 44 final ObjectUUID objectUUID = (ObjectUUID) o; 45 46 if(uuid != null ? !uuid.equals(objectUUID.uuid) : objectUUID.uuid != null) return false; 47 if(vmid != null ? !vmid.equals(objectUUID.vmid) : objectUUID.vmid != null) return false; 48 49 return true; 50 } 51 52 public int hashCode() { 53 int result; 54 result = (vmid != null ? vmid.hashCode() : 0); 55 result = 29 * result + (uuid != null ? uuid.hashCode() : 0); 56 return result; 57 } 58 59 public static void main(String [] args) { 60 System.out.println(new ObjectUUID().toString()); 61 System.out.println(new ObjectUUID().toString()); 62 System.out.println(new ObjectUUID().toString()); 63 System.out.println(new ObjectUUID().toString()); 64 System.out.println(new ObjectUUID().toString()); 65 } 66 } 67 | Popular Tags |