1 package org.apache.fulcrum.security.entity.impl;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 import org.apache.commons.lang3.builder.HashCodeBuilder;
24 import org.apache.fulcrum.security.entity.SecurityEntity;
25
26
27
28
29
30
31
32
33
34 public class SecurityEntityImpl implements SecurityEntity
35 {
36
37
38
39 private static final long serialVersionUID = 6949229336753158100L;
40
41 private String name;
42
43 private Object id;
44
45
46
47
48 public Object getId()
49 {
50 return id;
51 }
52
53
54
55
56 public void setId(Object id)
57 {
58 this.id = id;
59 }
60
61
62
63
64 public String getName()
65 {
66 return name;
67 }
68
69
70
71
72
73
74
75 public void setName(String name) throws IllegalArgumentException
76 {
77 if ( name == null )
78 {
79 throw new IllegalArgumentException("Must provide a valid name for all SecurityEntities.");
80 } else {
81 this.name = name.toLowerCase();
82 }
83 }
84
85 @Override
86 public String toString()
87 {
88 return getClass().getName() + " (id:" + getId() + " name:" + getName() + ")";
89 }
90
91
92
93
94
95
96 @Override
97 public boolean equals(Object o)
98 {
99 boolean equals = true;
100 Object id = getId();
101
102 if (o == null || id == null)
103 {
104 equals = false;
105 }
106 else if (!(o instanceof SecurityEntity))
107 {
108 equals = false;
109 }
110 else
111 {
112 equals = id.equals(((SecurityEntity) o).getId());
113 }
114 return equals;
115 }
116
117
118
119
120
121
122 @Override
123 public int hashCode()
124 {
125 return new HashCodeBuilder(47, 11).append(getId()).append(getName()).toHashCode();
126 }
127 }