1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package snifos.common;
21
22
23 /***
24 * This class represents id of a user in SNIFOS system.
25 * @version $Id: UserId.java,v 1.2 2004/05/08 21:55:29 mwerla Exp $
26 */
27 public class UserId {
28 private int commModuleId;
29 private int userIdInModule;
30 private String userId;
31
32 /***
33 * Creates new instance of UserId class.
34 * @param commModuleId Communication module to which user is connected.
35 * @param userIdInModule User id unique for the communication module
36 * to which user is connected.
37 */
38 public UserId(int commModuleId, int userIdInModule) {
39 this.commModuleId = commModuleId;
40 this.userIdInModule = userIdInModule;
41 this.userId = commModuleId + "|" + userIdInModule;
42 }
43
44 /***
45 * Checks equality of two user ids.
46 * @see java.lang.Object#equals(java.lang.Object)
47 * @param that UserId to compare.
48 * @return True if both ids represent the same user, otherwise false.
49 */
50 public boolean equals(UserId that) {
51 return (that != null) ? that.userId.equals(this.userId) : false;
52 }
53
54 /***
55 * Returns user id hashcode.
56 * @return Hash code of user id - baesd on its string representation.
57 */
58 public int hashCode() {
59 return userId.hashCode();
60 }
61
62 /***
63 * Returns string representation of this UserId instance.
64 * @return commModuleId + "|" + userIdInModule
65 */
66 public String toString() {
67 return userId;
68 }
69
70 /***
71 * Getter for commModuleId field.
72 * @see #UserId(int, int)
73 * @return commModuleId
74 */
75 public int getCommModuleId() {
76 return commModuleId;
77 }
78
79 /***
80 * Returns string representation of this UserId instance.
81 * @return commModuleId + "|" + userIdInModule
82 */
83 public String getUserId() {
84 return userId;
85 }
86
87 /***
88 * Getter for userIdInModule field.
89 * @see #UserId(int, int)
90 * @return userIdInModule
91 */
92 public int getUserIdInModule() {
93 return userIdInModule;
94 }
95 }