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:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description SecuritySet()Constructs an empty Set
-
Method Summary
All Methods Instance Methods Concrete Methods 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-
Methods 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 Detail
-
nameMap
protected Map<String,T extends SecurityEntity> nameMap
Map for "name" is "security object"
-
idMap
protected Map<Object,T extends SecurityEntity> idMap
Map for "id" is "security object"
-
-
Method Detail
-
getSet
public Set<T> getSet()
Returns a set of security objects in this object.- Returns:
- A Set Object
-
getNames
public Set<String> getNames()
Returns a set of Names in this Object.- Returns:
- The Set of Names in this Object, backed by the actual data.
-
getIds
public Set<Object> 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
public boolean containsName(String name)
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
public boolean containsId(Object id)
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
public Iterator<T> 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
public String toString()
list of role names in this set
-
add
public boolean add(T o)
- Specified by:
addin interfaceCollection<T extends SecurityEntity>- Specified by:
addin interfaceSet<T extends SecurityEntity>- See Also:
Collection.add(java.lang.Object)
-
add
public boolean add(Collection<? extends T> collection)
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
public boolean addAll(Collection<? extends T> collection)
- 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
public boolean containsAll(Collection<?> collection)
- Specified by:
containsAllin interfaceCollection<T extends SecurityEntity>- Specified by:
containsAllin interfaceSet<T extends SecurityEntity>
-
removeAll
public boolean removeAll(Collection<?> collection)
- Specified by:
removeAllin interfaceCollection<T extends SecurityEntity>- Specified by:
removeAllin interfaceSet<T extends SecurityEntity>
-
retainAll
public boolean retainAll(Collection<?> collection)
- Specified by:
retainAllin interfaceCollection<T extends SecurityEntity>- Specified by:
retainAllin interfaceSet<T extends SecurityEntity>
-
toArray
public Object[] toArray()
- Specified by:
toArrayin interfaceCollection<T extends SecurityEntity>- Specified by:
toArrayin interfaceSet<T extends SecurityEntity>
-
contains
public boolean contains(Object o)
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
public boolean remove(Object o)
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
public T getByName(String name)
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.
-
-