KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jfox > ioc > util > ObjectUUID


1 /* JFox, the OpenSource J2EE Application Server
2  *
3  * Distributable under GNU LGPL license by gun.org
4  * more details please visit http://www.huihoo.org/jfox
5  */

6
7 package org.jfox.ioc.util;
8
9 import java.io.Serializable JavaDoc;
10
11 /**
12  * @author <a HREF="mailto:young_yy@hotmail.com">Young Yang</a>
13  */

14
15 public class ObjectUUID implements Serializable JavaDoc {
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 JavaDoc toString() {
37         return vmid.toString() + "-" + uuid.toString();
38     }
39
40     public boolean equals(Object JavaDoc 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 JavaDoc[] 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