|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.shibboleth.metadata.util.ClassToInstanceMultiMap<B>
B - a bound for the types of values in the map@NotThreadSafe public final class ClassToInstanceMultiMap<B>
An append-only multimap where each entry associates a raw type (i.e. class) to instances of that class. In addition the map may also associate any supertype (i.e. all superclasses and interfaces implemented by the class) with the class. Null values are not supported.
| Field Summary | |
|---|---|
private HashMap<Class<?>,List<B>> |
backingMap
Map which backs this map. |
private boolean |
indexSupertypes
Whether supertypes should also be indexed. |
private List<B> |
values
List of values that are indexed. |
| Constructor Summary | |
|---|---|
ClassToInstanceMultiMap()
Constructor. |
|
ClassToInstanceMultiMap(boolean isIndexingSupertypes)
Constructor. |
|
| Method Summary | ||
|---|---|---|
void |
clear()
Removes all mappings from this map. |
|
boolean |
containsKey(Class<?> key)
Returns true if the map contains a mapping for the given key. |
|
boolean |
containsValue(B value)
Returns true if the map contains a mapping to the given value. |
|
boolean |
equals(Object obj)
|
|
|
get(Class<T> type)
Gets the instances mapped to the given type or an empty list, immutable, list otherwise. |
|
private void |
getSuperTypes(Class<?> clazz,
ArrayList<Class<?>> accumulator)
Gets all of the superclasses and interfaces implemented by the given class. |
|
int |
hashCode()
|
|
boolean |
isEmpty()
Returns true if this map contains no entries, false otherwise. |
|
Set<Class<?>> |
keys()
Gets the set of keys contained in this map. |
|
void |
put(B value)
Adds a value to this map. |
|
void |
putAll(ClassToInstanceMultiMap<? extends B> newValues)
Adds all the values to the map. |
|
void |
putAll(Iterable<? extends B> newValues)
Adds all the values to the map. |
|
Collection<? extends B> |
values()
The collection of values currently present in the map. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private final boolean indexSupertypes
private final HashMap<Class<?>,List<B>> backingMap
private final List<B> values
| Constructor Detail |
|---|
public ClassToInstanceMultiMap()
public ClassToInstanceMultiMap(boolean isIndexingSupertypes)
isIndexingSupertypes - indicates whether supertypes of a value should be indexed| Method Detail |
|---|
public void clear()
public boolean containsKey(Class<?> key)
key - key to check for in the map
public boolean containsValue(B value)
value - value to check for in this map
public <T> List<T> get(Class<T> type)
T - type identifiertype - map key
public boolean isEmpty()
public Set<Class<?>> keys()
public void put(B value)
indexSupertypes is false only the values class type is used as a key to the
value. If indexSupertypes is true, then the class types, all its supertypes, and all implemented
interfaces are used as keys to the value.
Duplicate values, as determined by the values Object.hashCode() and Object.equals(Object)
methods, are not stored. Only one instance of the value is ever stored in the map.
value - value to be stored in the mappublic void putAll(Iterable<? extends B> newValues)
newValues - values to be addedput(Object)public void putAll(ClassToInstanceMultiMap<? extends B> newValues)
newValues - values to be addedput(Object)public Collection<? extends B> values()
private void getSuperTypes(Class<?> clazz,
ArrayList<Class<?>> accumulator)
clazz - class for which supertypes will be determinedaccumulator - collection to which supertypes are added as they are determinedpublic int hashCode()
hashCode in class Objectpublic boolean equals(Object obj)
equals in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||