Class ValueTypeIndexedMap<KeyType,ValueType>
- java.lang.Object
-
- net.shibboleth.utilities.java.support.collection.ValueTypeIndexedMap<KeyType,ValueType>
-
- Type Parameters:
KeyType- the type of object used as keysValueType- the type of object stored as values
- All Implemented Interfaces:
Map<KeyType,ValueType>
@Beta public class ValueTypeIndexedMap<KeyType,ValueType> extends Object implements Map<KeyType,ValueType>
Map implementation which allows subsets of entries to be retrieved based on the type of the entry value.
-
-
Constructor Summary
Constructors Constructor Description ValueTypeIndexedMap()Constructor.ValueTypeIndexedMap(Collection<Class<?>> newTypes)Constructor.ValueTypeIndexedMap(Map<KeyType,ValueType> newMap, Collection<Class<?>> newTypes)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()booleancontainsKey(Object key)booleancontainsValue(Object value)Set<Map.Entry<KeyType,ValueType>>entrySet()booleanequals(Object obj)ValueTypeget(Object key)Set<Class<?>>getTypes()Get the value types that are indexed.inthashCode()booleanisEmpty()Set<KeyType>keySet()private BooleanmatchType(Class<?> type, Object object)Check if the object is of the specified type, taking null into account as well.ValueTypeput(KeyType key, ValueType value)voidputAll(Map<? extends KeyType,? extends ValueType> t)voidrebuildIndex()Rebuild internal index.ValueTyperemove(Object key)voidsetTypes(Collection<Class<?>> newTypes)Set which value types are indexed.intsize()<SubType extends ValueType>
Map<KeyType,SubType>subMap(Class<SubType> type)Returns an unmodifiable map of the entries whose value is of the specified type.StringtoString()Collection<ValueType>values()-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
-
-
-
Constructor Detail
-
ValueTypeIndexedMap
public ValueTypeIndexedMap()
Constructor.
-
ValueTypeIndexedMap
public ValueTypeIndexedMap(Map<KeyType,ValueType> newMap, Collection<Class<?>> newTypes)
Constructor.- Parameters:
newMap- existing map to build from.newTypes- collection of value types to index
-
ValueTypeIndexedMap
public ValueTypeIndexedMap(Collection<Class<?>> newTypes)
Constructor.- Parameters:
newTypes- collection of value types to index
-
-
Method Detail
-
containsKey
public boolean containsKey(Object key)
- Specified by:
containsKeyin interfaceMap<KeyType,ValueType>
-
containsValue
public boolean containsValue(Object value)
- Specified by:
containsValuein interfaceMap<KeyType,ValueType>
-
getTypes
public Set<Class<?>> getTypes()
Get the value types that are indexed.- Returns:
- which value types are indexed
-
matchType
private Boolean matchType(Class<?> type, Object object)
Check if the object is of the specified type, taking null into account as well.- Parameters:
type- type to check forobject- object to check- Returns:
- true if the object is of the specified type
-
rebuildIndex
public void rebuildIndex()
Rebuild internal index.
-
setTypes
public void setTypes(Collection<Class<?>> newTypes)
Set which value types are indexed.- Parameters:
newTypes- which value types are indexed
-
subMap
public <SubType extends ValueType> Map<KeyType,SubType> subMap(Class<SubType> type)
Returns an unmodifiable map of the entries whose value is of the specified type.- Type Parameters:
SubType- type of values to include in the returned map- Parameters:
type- type of values to return- Returns:
- sub map of entries whose value is of type SubType or empty if the specified type is not a valid type for this map.
-
hashCode
public int hashCode()
-
equals
public boolean equals(Object obj)
-
-