2 * Copyright 2005 the original author or authors.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package org.wamblee.usermgt;
20 import java.util.TreeSet;
23 * In-memory group set implementation.
25 public class InMemoryGroupSet implements GroupSet {
30 private Set<Group> _groups;
33 * Constructs an empty group set.
35 public InMemoryGroupSet() {
36 _groups = new TreeSet<Group>();
40 * @see org.wamblee.usermgt.GroupSet#groupModified(org.wamblee.usermgt.Group)
42 public void groupModified(Group aGroup) {
43 _groups.remove(aGroup);
48 * @see org.wamblee.usermgt.GroupSet#find(java.lang.String)
50 public Group find(String aName) {
51 for (Group group: _groups) {
52 if ( group.getName().equals(aName)) {
53 return new Group(group);
60 * @see org.wamblee.usermgt.GroupSet#contains(org.wamblee.usermgt.Group)
62 public boolean contains(Group aGroup) {
63 return _groups.contains(aGroup);
67 * @see org.wamblee.usermgt.GroupSet#add(org.wamblee.usermgt.Group)
69 public boolean add(Group aGroup) {
70 return _groups.add(aGroup);
74 * @see org.wamblee.usermgt.GroupSet#remove(org.wamblee.usermgt.Group)
76 public boolean remove(Group aGroup) {
77 return _groups.remove(aGroup);
81 * @see org.wamblee.usermgt.GroupSet#list()
83 public Set<Group> list() {
84 Set<Group> list = new TreeSet<Group>();
85 for (Group group: _groups) {
86 list.add(new Group(group));
92 * @see org.wamblee.usermgt.GroupSet#size()
95 return _groups.size();