1 package org.sourceforge.jemm.comm.server;
2
3 import java.util.concurrent.atomic.AtomicInteger;
4
5
6
7
8
9
10
11
12
13 public class RPCClientId {
14
15 protected static final AtomicInteger ID_SOURCE = new AtomicInteger(1);
16
17
18 protected final String clientIdString;
19
20
21
22
23 public RPCClientId() {
24 this("CL:" + ID_SOURCE.getAndIncrement());
25 }
26
27
28
29
30
31 public RPCClientId(String internalId) {
32 if(internalId == null)
33 throw new IllegalArgumentException("rpc client id cannot be null");
34
35 this.clientIdString = internalId;
36 }
37
38
39
40
41
42 public String getInternalId() {
43 return clientIdString;
44 }
45
46 @Override
47 public boolean equals(Object obj) {
48 if (this == obj)
49 return true;
50 if (obj == null)
51 return false;
52 if (getClass() != obj.getClass())
53 return false;
54 final RPCClientId other = (RPCClientId) obj;
55 return clientIdString.equals(other.clientIdString);
56 }
57
58 @Override
59 public int hashCode() {
60 return clientIdString.hashCode();
61 }
62
63 @Override
64 public String toString() {
65 return "ClientId(" + clientIdString + ")";
66 }
67 }