01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package com.tc.object.lockmanager.api;
05:
06: import java.io.Serializable;
07:
08: import com.tc.util.Assert;
09:
10: /**
11: * Identifier for a given lock
12: *
13: * @author steve
14: */
15: public class LockID implements Serializable {
16: /** Indicates no lock identifier */
17: public final static LockID NULL_ID = new LockID("null id");
18: private final String id;
19:
20: /**
21: * New id
22: * @param id ID value
23: */
24: public LockID(String id) {
25: Assert.eval(id != null);
26: this .id = id;
27: }
28:
29: /**
30: * @return True if is null identifier
31: */
32: public boolean isNull() {
33: return this == NULL_ID;
34: }
35:
36: /**
37: * @return ID type
38: */
39: public String getIdentifierType() {
40: return "LockID";
41: }
42:
43: /**
44: * @return String value of id value
45: */
46: public String asString() {
47: return id;
48: }
49:
50: public String toString() {
51: return getIdentifierType() + "(" + id + ")";
52: }
53:
54: public int hashCode() {
55: return id.hashCode();
56: }
57:
58: public boolean equals(Object obj) {
59: if (obj instanceof LockID) {
60: LockID lid = (LockID) obj;
61: return this .id.equals(lid.id);
62: }
63: return false;
64: }
65: }
|