|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.util.AbstractCollection<E> java.util.AbstractSet<T> org.opensaml.xml.util.ClassIndexedSet<T>
T
- the type of object stored by this classpublic class ClassIndexedSet<T>
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 | |
---|---|
protected class |
ClassIndexedSet.ClassIndexedSetIterator
Iterator for set implementation ClassIndexedSet . |
Field Summary | |
---|---|
private HashMap<Class<? extends T>,T> |
index
Storage for index of class -> member. |
private HashSet<T> |
set
Storage for set members. |
Constructor Summary | |
---|---|
ClassIndexedSet()
Constructor. |
Method Summary | ||
---|---|---|
boolean |
add(T o)
|
|
boolean |
add(T o,
boolean replace)
Add member to set, optionally replacing any existing instance of the same class. |
|
void |
clear()
|
|
boolean |
contains(Class<? extends T> clazz)
Check whether set contains an instance of the specified class. |
|
|
get(Class<X> clazz)
Get the set element specified by the class parameter. |
|
protected Class<? extends T> |
getIndexClass(Object o)
Get the index class of the specified object. |
|
Iterator<T> |
iterator()
|
|
boolean |
remove(Object o)
|
|
private void |
removeFromIndex(T o)
Remove the specified object from the index. |
|
int |
size()
|
Methods inherited from class java.util.AbstractSet |
---|
equals, hashCode, removeAll |
Methods inherited from class java.util.AbstractCollection |
---|
addAll, contains, containsAll, isEmpty, retainAll, toArray, toArray, toString |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Set |
---|
addAll, contains, containsAll, equals, hashCode, isEmpty, removeAll, retainAll, toArray, toArray |
Field Detail |
---|
private HashSet<T> set
private HashMap<Class<? extends T>,T> index
Constructor Detail |
---|
public ClassIndexedSet()
Method Detail |
---|
public boolean add(T o)
add
in interface Collection<T>
add
in interface Set<T>
add
in class AbstractCollection<T>
public boolean add(T o, boolean replace) throws NullPointerException, IllegalArgumentException
o
- the object to addreplace
- flag indicating whether to replace an existing class type
IllegalArgumentException
- if set already contained an instance of the object's class
and replacement was specified as false
NullPointerException
- if the object to add was nullpublic void clear()
clear
in interface Collection<T>
clear
in interface Set<T>
clear
in class AbstractCollection<T>
public boolean remove(Object o)
remove
in interface Collection<T>
remove
in interface Set<T>
remove
in class AbstractCollection<T>
public Iterator<T> iterator()
iterator
in interface Iterable<T>
iterator
in interface Collection<T>
iterator
in interface Set<T>
iterator
in class AbstractCollection<T>
public int size()
size
in interface Collection<T>
size
in interface Set<T>
size
in class AbstractCollection<T>
public boolean contains(Class<? extends T> clazz)
clazz
- the class to check
public <X extends T> X get(Class<X> clazz)
X
- generic parameter which eliminates need for casting by the callerclazz
- the class to whose instance is to be retrieved
protected Class<? extends T> getIndexClass(Object o)
o
- the object whose class index to determine
private void removeFromIndex(T o)
o
- the object to remove
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |