Removed DOCUMENT ME comments that were generated and applied source code
[utils] / security / src / main / java / org / wamblee / usermgt / InMemoryGroupSet.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 package org.wamblee.usermgt;
17
18 import java.util.Set;
19 import java.util.TreeSet;
20
21 /**
22  * In-memory group set implementation.
23  * 
24  * @author Erik Brakkee
25  */
26 public class InMemoryGroupSet implements GroupSet {
27     /**
28      * Groups.
29      */
30     private Set<Group> groups;
31
32     /**
33      * Constructs an empty group set.
34      */
35     public InMemoryGroupSet() {
36         groups = new TreeSet<Group>();
37     }
38
39     /*
40      * (non-Javadoc)
41      * 
42      * @see
43      * org.wamblee.usermgt.GroupSet#groupModified(org.wamblee.usermgt.Group)
44      */
45     public void groupModified(Group aGroup) {
46         groups.remove(aGroup);
47         groups.add(aGroup);
48     }
49
50     /*
51      * (non-Javadoc)
52      * 
53      * @see org.wamblee.usermgt.GroupSet#find(java.lang.String)
54      */
55     public Group find(String aName) {
56         for (Group group : groups) {
57             if (group.getName().equals(aName)) {
58                 return new Group(group);
59             }
60         }
61
62         return null;
63     }
64
65     /*
66      * (non-Javadoc)
67      * 
68      * @see org.wamblee.usermgt.GroupSet#contains(org.wamblee.usermgt.Group)
69      */
70     public boolean contains(Group aGroup) {
71         return groups.contains(aGroup);
72     }
73
74     /*
75      * (non-Javadoc)
76      * 
77      * @see org.wamblee.usermgt.GroupSet#add(org.wamblee.usermgt.Group)
78      */
79     public boolean add(Group aGroup) {
80         return groups.add(aGroup);
81     }
82
83     /*
84      * (non-Javadoc)
85      * 
86      * @see org.wamblee.usermgt.GroupSet#remove(org.wamblee.usermgt.Group)
87      */
88     public boolean remove(Group aGroup) {
89         return groups.remove(aGroup);
90     }
91
92     /*
93      * (non-Javadoc)
94      * 
95      * @see org.wamblee.usermgt.GroupSet#list()
96      */
97     public Set<Group> list() {
98         Set<Group> list = new TreeSet<Group>();
99
100         for (Group group : groups) {
101             list.add(new Group(group));
102         }
103
104         return list;
105     }
106
107     /*
108      * (non-Javadoc)
109      * 
110      * @see org.wamblee.usermgt.GroupSet#size()
111      */
112     public int size() {
113         return groups.size();
114     }
115 }