1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 package org.talika.tarsis.security;
24
25 import java.io.Serializable;
26
27 /**
28 * Implementation of <code>Role</code> interface.
29 *
30 * @author Jose M. Palomar
31 * @version $Revision: 124 $
32 */
33 public final class RoleImpl implements Role, Serializable {
34
35
36 /**
37 * Name of role.
38 */
39 private final String name;
40
41
42 /**
43 * Creates a new <code>RoleImpl</code>.
44 *
45 * @param name String name of role.
46 */
47 public RoleImpl(String name) {
48 this.name = name;
49 }
50
51
52 /**
53 * Returns name of role.
54 *
55 * @return String name of role.
56 * @see org.talika.tarsis.security.Role#getName()
57 */
58 public String getName() {
59 return name;
60 }
61
62 /**
63 * Indicates whether some other object is "equal to" this one.
64 *
65 * @param obj Object the reference object with which to compare.
66 * @return boolean <code>true</code> if this object is the same as the obj
67 * argument; <code>false</code> otherwise.
68 */
69 public boolean equals(Object obj) {
70 return ((obj instanceof Role) && ((Role) obj).getName().equals(this.name));
71 }
72
73 /**
74 * Returns a hash code value for the object.
75 *
76 * @return int a hash code value for this object.
77 */
78 public int hashCode() {
79 return this.name.hashCode();
80 }
81
82 /**
83 * Returns a string representation of the object.
84 *
85 * @return String a string representation of the object.
86 */
87 public String toString() {
88 return name;
89 }
90
91 }