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: SecuritySet.java 1856202 2019-03-25 14:29:46Z painter $
- Author:
- Eric Pugh, John D. McNally, Brett McLaughlin, Marco Knüttel, Henning P. Schmiedehausen
- See Also:
- Serialized Form
-
Field Summary
-
Constructor Summary
Constructors Constructor Description SecuritySet()Constructs an empty Set -
Method Summary
Modifier and Type Method Description booleanadd(Collection<? extends T> collection)Adds the entities in a Collection to this SecuritySet.booleanadd(T o)booleanaddAll(Collection<? extends T> collection)voidclear()Removes all Objects from this Set.booleancontains(Object o)Checks whether this SecuritySet contains an entity.booleancontainsAll(Collection<?> collection)booleancontainsId(Object id)Searches if an Object with a given Id is in the SetbooleancontainsName(String name)Searches if an Object with a given name is in the SetTgetById(Object id)Returns an entity with the given id, if it is contained in this SecuritySet.TgetByName(String name)Returns an entity with the given name, if it is contained in this SecuritySet.Set<Object>getIds()Returns a set of Id values in this Object.Set<String>getNames()Returns a set of Names in this Object.Set<T>getSet()Returns a set of security objects in this object.booleanisEmpty()Iterator<T>iterator()Returns an Iterator for Objects in this Set.booleanremove(Object o)Removes an entity from this SecuritySet.booleanremoveAll(Collection<?> collection)booleanretainAll(Collection<?> collection)intsize()Returns size (cardinality) of this set.Object[]toArray()<A> A[]toArray(A[] a)StringtoString()list of role names in this set
-
Field Details
-
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:
clearin interfaceCollection<T extends SecurityEntity>- Specified by:
clearin 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:
iteratorin interfaceCollection<T extends SecurityEntity>- Specified by:
iteratorin interfaceIterable<T extends SecurityEntity>- Specified by:
iteratorin interfaceSet<T extends SecurityEntity>- Returns:
- An iterator for the Set
-
size
public int size()Returns size (cardinality) of this set.- Specified by:
sizein interfaceCollection<T extends SecurityEntity>- Specified by:
sizein interfaceSet<T extends SecurityEntity>- Returns:
- The cardinality of this Set.
-
toString
list of role names in this set -
add
- Specified by:
addin interfaceCollection<T extends SecurityEntity>- Specified by:
addin interfaceSet<T extends SecurityEntity>- See Also:
Collection.add(java.lang.Object)
-
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:
addAllin interfaceCollection<T extends SecurityEntity>- Specified by:
addAllin interfaceSet<T extends SecurityEntity>
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceCollection<T extends SecurityEntity>- Specified by:
isEmptyin interfaceSet<T extends SecurityEntity>
-
containsAll
- Specified by:
containsAllin interfaceCollection<T extends SecurityEntity>- Specified by:
containsAllin interfaceSet<T extends SecurityEntity>
-
removeAll
- Specified by:
removeAllin interfaceCollection<T extends SecurityEntity>- Specified by:
removeAllin interfaceSet<T extends SecurityEntity>
-
retainAll
- Specified by:
retainAllin interfaceCollection<T extends SecurityEntity>- Specified by:
retainAllin interfaceSet<T extends SecurityEntity>
-
toArray
- Specified by:
toArrayin interfaceCollection<T extends SecurityEntity>- Specified by:
toArrayin interfaceSet<T extends SecurityEntity>
-
contains
Checks whether this SecuritySet contains an entity.- Specified by:
containsin interfaceCollection<T extends SecurityEntity>- Specified by:
containsin 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:
removein interfaceCollection<T extends SecurityEntity>- Specified by:
removein 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:
toArrayin interfaceCollection<T extends SecurityEntity>- Specified by:
toArrayin 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.
-