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 Details

  • Constructor Details

    • SecuritySet

      public SecuritySet()
      Constructs an empty Set
  • Method Details

    • 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:
      clear in interface Collection<T extends SecurityEntity>
      Specified by:
      clear in interface Set<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:
      iterator in interface Collection<T extends SecurityEntity>
      Specified by:
      iterator in interface Iterable<T extends SecurityEntity>
      Specified by:
      iterator in interface Set<T extends SecurityEntity>
      Returns:
      An iterator for the Set
    • size

      public int size()
      Returns size (cardinality) of this set.
      Specified by:
      size in interface Collection<T extends SecurityEntity>
      Specified by:
      size in interface Set<T extends SecurityEntity>
      Returns:
      The cardinality of this Set.
    • toString

      public String toString()
      list of role names in this set
      Overrides:
      toString in class Object
      Returns:
      The string representation of this Set.
    • add

      public boolean add(T o)
      Specified by:
      add in interface Collection<T extends SecurityEntity>
      Specified by:
      add in interface Set<T extends SecurityEntity>
      See Also:
    • 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:
      addAll in interface Collection<T extends SecurityEntity>
      Specified by:
      addAll in interface Set<T extends SecurityEntity>
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface Collection<T extends SecurityEntity>
      Specified by:
      isEmpty in interface Set<T extends SecurityEntity>
    • containsAll

      public boolean containsAll(Collection<?> collection)
      Specified by:
      containsAll in interface Collection<T extends SecurityEntity>
      Specified by:
      containsAll in interface Set<T extends SecurityEntity>
    • removeAll

      public boolean removeAll(Collection<?> collection)
      Specified by:
      removeAll in interface Collection<T extends SecurityEntity>
      Specified by:
      removeAll in interface Set<T extends SecurityEntity>
    • retainAll

      public boolean retainAll(Collection<?> collection)
      Specified by:
      retainAll in interface Collection<T extends SecurityEntity>
      Specified by:
      retainAll in interface Set<T extends SecurityEntity>
    • toArray

      public Object[] toArray()
      Specified by:
      toArray in interface Collection<T extends SecurityEntity>
      Specified by:
      toArray in interface Set<T extends SecurityEntity>
    • contains

      public boolean contains(Object o)
      Checks whether this SecuritySet contains an entity.
      Specified by:
      contains in interface Collection<T extends SecurityEntity>
      Specified by:
      contains in interface Set<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:
      remove in interface Collection<T extends SecurityEntity>
      Specified by:
      remove in interface Set<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 interface Collection<T extends SecurityEntity>
      Specified by:
      toArray in interface Set<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.
    • getById

      public T getById(Object id)
      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.