01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright
03: * notice. All rights reserved.
04: */
05: package com.tc.object.lockmanager.api;
06:
07: import com.tc.net.groups.ClientID;
08: import com.tc.net.groups.NodeID;
09:
10: public class ServerThreadID {
11: public static final ServerThreadID NULL_ID = new ServerThreadID(
12: ClientID.NULL_ID, ThreadID.NULL_ID);
13:
14: private final NodeID nodeID;
15: private final ThreadID threadID;
16: private final int hashCode;
17:
18: public ServerThreadID(NodeID nid, ThreadID threadID) {
19: this .nodeID = nid;
20: this .threadID = threadID;
21:
22: int hash = 31;
23: hash = (37 * hash) + nid.hashCode();
24: hash = (37 * hash) + threadID.hashCode();
25: this .hashCode = hash;
26: }
27:
28: public NodeID getNodeID() {
29: return nodeID;
30: }
31:
32: public ThreadID getClientThreadID() {
33: return threadID;
34: }
35:
36: public String toString() {
37: return new StringBuffer().append("ServerThreadID{").append(
38: nodeID).append(',').append(threadID).append('}')
39: .toString();
40: }
41:
42: public int hashCode() {
43: return this .hashCode;
44: }
45:
46: public boolean equals(Object obj) {
47: if (obj instanceof ServerThreadID) {
48: ServerThreadID other = (ServerThreadID) obj;
49: return this .nodeID.equals(other.nodeID)
50: && this .threadID.equals(other.threadID);
51: }
52: return false;
53: }
54: }
|