Package net.shibboleth.shared.collection
Class ClassIndexedSet<T>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractSet<T>
net.shibboleth.shared.collection.ClassIndexedSet<T>
- Type Parameters:
T- the type of object stored by this class
- All Implemented Interfaces:
Iterable<T>,Collection<T>,Set<T>
- Direct Known Subclasses:
CriteriaSet
Set implementation which provides indexed access to set members via their class, and which allows only one instance
of a given class to be present in the set. Null members are not allowed.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classIterator for set implementationClassIndexedSet. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleanAdd member to set, optionally replacing any existing instance of the same class.voidclear()booleanCheck whether set contains an instance of the specified class.boolean<X extends T>
XGet the set element specified by the class parameter.getIndexClass(X o) Get the index class of the specified object.inthashCode()iterator()booleanprivate voidremoveFromIndex(T o) Remove the specified object from the index.intsize()toString()Methods inherited from class java.util.AbstractSet
removeAllMethods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, retainAll, toArray, toArrayMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface java.util.Set
addAll, contains, containsAll, isEmpty, removeAll, retainAll, spliterator, toArray, toArray
-
Field Details
-
set
Storage for set members. -
index
Storage for index of class -> member.
-
-
Constructor Details
-
ClassIndexedSet
public ClassIndexedSet()Constructor.
-
-
Method Details
-
add
- Specified by:
addin interfaceCollection<T>- Specified by:
addin interfaceSet<T>- Overrides:
addin classAbstractCollection<T>
-
add
Add member to set, optionally replacing any existing instance of the same class.- Parameters:
o- the object to addreplace- flag indicating whether to replace an existing class type- Returns:
- true if object was added
-
clear
public void clear()- Specified by:
clearin interfaceCollection<T>- Specified by:
clearin interfaceSet<T>- Overrides:
clearin classAbstractCollection<T>
-
remove
- Specified by:
removein interfaceCollection<T>- Specified by:
removein interfaceSet<T>- Overrides:
removein classAbstractCollection<T>
-
iterator
-
size
public int size()- Specified by:
sizein interfaceCollection<T>- Specified by:
sizein interfaceSet<T>- Specified by:
sizein classAbstractCollection<T>
-
contains
Check whether set contains an instance of the specified class.- Parameters:
clazz- the class to check- Returns:
- true if set contains an instance of the specified class, false otherwise
-
get
Get the set element specified by the class parameter.- Type Parameters:
X- generic parameter which eliminates need for casting by the caller- Parameters:
clazz- the class to whose instance is to be retrieved- Returns:
- the element whose class is of the type specified
-
getIndexClass
Get the index class of the specified object. Subclasses may override to use a class index other than the main runtime class of the object.- Type Parameters:
X- generic parameter which eliminates need for casting by the caller- Parameters:
o- the object whose class index to determine- Returns:
- the class index value associated with the object instance
-
removeFromIndex
Remove the specified object from the index.- Parameters:
o- the object to remove
-
toString
- Overrides:
toStringin classAbstractCollection<T>
-
equals
- Specified by:
equalsin interfaceCollection<T>- Specified by:
equalsin interfaceSet<T>- Overrides:
equalsin classAbstractSet<T>
-
hashCode
public int hashCode()- Specified by:
hashCodein interfaceCollection<T>- Specified by:
hashCodein interfaceSet<T>- Overrides:
hashCodein classAbstractSet<T>
-