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