e67d7bcf75f415a171f2b8f07876675a83e70a9b
[utils] / security / src / main / java / org / wamblee / usermgt / GroupSet.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.util.Set;
20
21 /**
22  * Represents a set of groups. A typical implemnetation would be, a readonly implementation 
23  * defined in a configuration file or a list of groups defined in a database. 
24  */
25 public interface GroupSet {
26     
27     /**
28      * Must be called when the group has been modified to notify the group set. 
29      * @param aGroup Group that was modified. 
30      */
31     void groupModified(Group aGroup); 
32     
33     /**
34      * Finds the group by name. 
35      * @param aName Group name. 
36      * @return Group or null if not found. 
37      */
38     Group find(String aName);
39     
40     /**
41      * Determines if the group exists. 
42      * @param aGroup Group. 
43      * @return True iff the group exists. 
44      */
45     boolean contains(Group aGroup);
46  
47     /**
48      * Adds a group. If the group already exists, the existing group set
49      * is left unchanged.   
50      * @param aGroup Group.
51      */
52     boolean add(Group aGroup);
53     
54     /**
55      * Removes a group. If the group does not exist, this method is a no-op. 
56      * @param aGroup Group to remove.
57      * @return True if the group was removed, false otherwise.  
58      */
59     boolean remove(Group aGroup);
60    
61     /**
62      * Returns the current groups. 
63      * @return Groups. 
64      */
65     Set<Group> list();
66
67     /**
68      * @return The number of groups. 
69      */
70     int size(); 
71 }