KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > object > lockmanager > api > LockID


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package com.tc.object.lockmanager.api;
5
6 import java.io.Serializable JavaDoc;
7
8 import com.tc.util.Assert;
9
10 /**
11  * Identifier for a given lock
12  *
13  * @author steve
14  */

15 public class LockID implements Serializable JavaDoc {
16   public final static LockID NULL_ID = new LockID("null id");
17   private final String JavaDoc id;
18
19   public LockID(String JavaDoc id) {
20     Assert.eval(id != null);
21     this.id = id;
22   }
23
24   public boolean isNull() {
25     return this == NULL_ID;
26   }
27
28   public String JavaDoc getIdentifierType() {
29     return "LockID";
30   }
31
32   public String JavaDoc asString() {
33     return id;
34   }
35
36   public String JavaDoc toString() {
37     return getIdentifierType() + "(" + id + ")";
38   }
39
40   public int hashCode() {
41     return id.hashCode();
42   }
43
44   public boolean equals(Object JavaDoc obj) {
45     if (obj instanceof LockID) {
46       LockID lid = (LockID) obj;
47       return this.id.equals(lid.id);
48     }
49     return false;
50   }
51 }
52
Popular Tags