780d60bb72f8ff02464c44739093e535a17e4f74
[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  * @author Erik Brakkee
26  */
27 public interface GroupSet {
28     
29     /**
30      * Must be called when the group has been modified to notify the group set. 
31      * @param aGroup Group that was modified. 
32      */
33     void groupModified(Group aGroup); 
34     
35     /**
36      * Finds the group by name. 
37      * @param aName Group name. 
38      * @return Group or null if not found. 
39      */
40     Group find(String aName);
41     
42     /**
43      * Determines if the group exists. 
44      * @param aGroup Group. 
45      * @return True iff the group exists. 
46      */
47     boolean contains(Group aGroup);
48  
49     /**
50      * Adds a group. If the group already exists, the existing group set
51      * is left unchanged.   
52      * @param aGroup Group.
53      */
54     boolean add(Group aGroup);
55     
56     /**
57      * Removes a group. If the group does not exist, this method is a no-op. 
58      * @param aGroup Group to remove.
59      * @return True if the group was removed, false otherwise.  
60      */
61     boolean remove(Group aGroup);
62    
63     /**
64      * Returns the current groups. 
65      * @return Groups. 
66      */
67     Set<Group> list();
68
69     /**
70      * @return The number of groups. 
71      */
72     int size(); 
73 }