a853541752dc171ad99b83392ed89ecec489cf7e
[utils] / security / src / main / java / org / wamblee / usermgt / Group.java
1 /*
2  * Copyright 2005 the original author or authors.
3  * 
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  * 
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  * 
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */ 
16
17 package org.wamblee.usermgt;
18
19 import java.io.Serializable;
20
21 import org.wamblee.persistence.AbstractPersistent;
22
23 /**
24  * Represents a group. 
25  *
26  * @author Erik Brakkee
27  */
28 public class Group extends AbstractPersistent implements Serializable, Comparable {
29
30     /**
31      * Group name. 
32      */
33     private String name;  
34
35     /**
36      * Constructs the group. 
37      * @param aName
38      */
39     Group(String aName) {
40         super();
41         name = aName; 
42     }
43     
44     public Group(Group aGroup) { 
45         super(aGroup); 
46         name = aGroup.name;
47     }
48     
49     protected Group() { 
50         super(); 
51         name = null; 
52     }
53     
54     /**
55      * Gets the name of the group. 
56      * @return Group name. 
57      */
58     public String getName() { 
59         return name; 
60     }
61     
62     /**
63      * Sets the group name. 
64      * @param aName Group name. 
65      */
66     void setName(String aName) {
67         name = aName; 
68     }
69     
70     /* (non-Javadoc)
71      * @see java.lang.Object#equals(java.lang.Object)
72      */
73     @Override
74     public boolean equals(Object aGroup) {
75         if ( !( aGroup instanceof Group )) { 
76             return false; 
77         }
78         return name.equals(((Group)aGroup).name);
79     }
80     
81     /* (non-Javadoc)
82      * @see java.lang.Object#hashCode()
83      */
84     @Override
85     public int hashCode() {
86         return name.hashCode(); 
87     }
88     
89     /* (non-Javadoc)
90      * @see java.lang.Comparable#compareTo(T)
91      */
92     public int compareTo(Object aGroup) {
93         return name.compareTo(((Group)aGroup).name);
94     }
95     
96     /* (non-Javadoc)
97      * @see java.lang.Object#toString()
98      */
99     @Override
100     public String toString() {
101         return "Group(pk = " + getPrimaryKey() + ", name=" + name + ")";
102     }
103 }