Package org.apache.fulcrum.security.util
Class SecuritySet<T extends SecurityEntity>
java.lang.Object
org.apache.fulcrum.security.util.SecuritySet<T>
- All Implemented Interfaces:
Serializable
,Iterable<T>
,Collection<T>
,Set<T>
- Direct Known Subclasses:
GroupSet
,PermissionSet
,RoleSet
,UserSet
public abstract class SecuritySet<T extends SecurityEntity>
extends Object
implements Serializable, Set<T>, Iterable<T>
This class represents a set of Security Entities. It makes it easy to build a
UI. It wraps a TreeSet object to enforce that only relevant methods are
available. TreeSet's contain only unique Objects (no duplicates) based on the
ID. They may or may not have a name, that depends on the implementation. Want
to get away from requiring an ID and a name... Nothing should force Name to
be unique in the basic architecture of Fulcrum Security.
- Version:
- $Id$
- Author:
- Eric Pugh, John D. McNally, Brett McLaughlin, Marco Knüttel, Henning P. Schmiedehausen
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
add
(Collection<? extends T> collection) Adds the entities in a Collection to this SecuritySet.boolean
boolean
addAll
(Collection<? extends T> collection) void
clear()
Removes all Objects from this Set.boolean
Checks whether this SecuritySet contains an entity.boolean
containsAll
(Collection<?> collection) boolean
containsId
(Object id) Searches if an Object with a given Id is in the Setboolean
containsName
(String name) Searches if an Object with a given name is in the SetReturns an entity with the given id, if it is contained in this SecuritySet.Returns an entity with the given name, if it is contained in this SecuritySet.getIds()
Returns a set of Id values in this Object.getNames()
Returns a set of Names in this Object.getSet()
Returns a set of security objects in this object.boolean
isEmpty()
iterator()
Returns an Iterator for Objects in this Set.boolean
Removes an entity from this SecuritySet.boolean
removeAll
(Collection<?> collection) boolean
retainAll
(Collection<?> collection) int
size()
Returns size (cardinality) of this set.Object[]
toArray()
<A> A[]
toArray
(A[] a) toString()
list of role names in this setMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
Methods inherited from interface java.util.Set
equals, hashCode, spliterator
-
Field Details
-
nameMap
Map for "name" is "security object" -
idMap
Map for "id" is "security object"
-
-
Constructor Details
-
SecuritySet
public SecuritySet()Constructs an empty Set
-
-
Method Details
-
getSet
Returns a set of security objects in this object.- Returns:
- A Set Object
-
getNames
Returns a set of Names in this Object.- Returns:
- The Set of Names in this Object, backed by the actual data.
-
getIds
Returns a set of Id values in this Object.- Returns:
- The Set of Ids in this Object, backed by the actual data.
-
clear
public void clear()Removes all Objects from this Set.- Specified by:
clear
in interfaceCollection<T extends SecurityEntity>
- Specified by:
clear
in interfaceSet<T extends SecurityEntity>
-
containsName
Searches if an Object with a given name is in the Set- Parameters:
name
- Name of the Security Object.- Returns:
- True if argument matched an Object in this Set; false if no match.
-
containsId
Searches if an Object with a given Id is in the Set- Parameters:
id
- Id of the Security Object.- Returns:
- True if argument matched an Object in this Set; false if no match.
-
iterator
Returns an Iterator for Objects in this Set.- Specified by:
iterator
in interfaceCollection<T extends SecurityEntity>
- Specified by:
iterator
in interfaceIterable<T extends SecurityEntity>
- Specified by:
iterator
in interfaceSet<T extends SecurityEntity>
- Returns:
- An iterator for the Set
-
size
public int size()Returns size (cardinality) of this set.- Specified by:
size
in interfaceCollection<T extends SecurityEntity>
- Specified by:
size
in interfaceSet<T extends SecurityEntity>
- Returns:
- The cardinality of this Set.
-
toString
list of role names in this set -
add
- Specified by:
add
in interfaceCollection<T extends SecurityEntity>
- Specified by:
add
in interfaceSet<T extends SecurityEntity>
- See Also:
-
add
Adds the entities in a Collection to this SecuritySet.- Parameters:
collection
- A Collection of entities.- Returns:
- True if this Set changed as a result; false if no change to this Set occurred (this Set already contained all members of the added Set).
-
addAll
- Specified by:
addAll
in interfaceCollection<T extends SecurityEntity>
- Specified by:
addAll
in interfaceSet<T extends SecurityEntity>
-
isEmpty
public boolean isEmpty()- Specified by:
isEmpty
in interfaceCollection<T extends SecurityEntity>
- Specified by:
isEmpty
in interfaceSet<T extends SecurityEntity>
-
containsAll
- Specified by:
containsAll
in interfaceCollection<T extends SecurityEntity>
- Specified by:
containsAll
in interfaceSet<T extends SecurityEntity>
-
removeAll
- Specified by:
removeAll
in interfaceCollection<T extends SecurityEntity>
- Specified by:
removeAll
in interfaceSet<T extends SecurityEntity>
-
retainAll
- Specified by:
retainAll
in interfaceCollection<T extends SecurityEntity>
- Specified by:
retainAll
in interfaceSet<T extends SecurityEntity>
-
toArray
- Specified by:
toArray
in interfaceCollection<T extends SecurityEntity>
- Specified by:
toArray
in interfaceSet<T extends SecurityEntity>
-
contains
Checks whether this SecuritySet contains an entity.- Specified by:
contains
in interfaceCollection<T extends SecurityEntity>
- Specified by:
contains
in interfaceSet<T extends SecurityEntity>
- Parameters:
o
- An entity.- Returns:
- True if this Set contains the entity, false otherwise.
-
remove
Removes an entity from this SecuritySet.- Specified by:
remove
in interfaceCollection<T extends SecurityEntity>
- Specified by:
remove
in interfaceSet<T extends SecurityEntity>
- Parameters:
o
- An entity.- Returns:
- True if this Set contained the entity before it was removed.
-
toArray
public <A> A[] toArray(A[] a) - Specified by:
toArray
in interfaceCollection<T extends SecurityEntity>
- Specified by:
toArray
in interfaceSet<T extends SecurityEntity>
-
getByName
Returns an entity with the given name, if it is contained in this SecuritySet.- Parameters:
name
- Name of entity.- Returns:
- entity if argument matched an entity in this Set; null if no match.
-
getById
Returns an entity with the given id, if it is contained in this SecuritySet.- Parameters:
id
- ID of entity.- Returns:
- entity if argument matched an entity in this Set; null if no match.
-