Package net.shibboleth.shared.collection

# Class ValueTypeIndexedMap<KeyType,ValueType>

java.lang.Object
net.shibboleth.shared.collection.ValueTypeIndexedMap<KeyType,ValueType>

Type Parameters:
  `KeyType` - the type of object used as keys
  `ValueType` - the type of object stored as values

All Implemented Interfaces:
  `Map<KeyType,ValueType>`

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.

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`private static class`
`ValueTypeIndexedMap.NullValue`
Class to represent null values.

## Nested classes/interfaces inherited from interface java.util.Map

`Map.Entry<K extends Object,V extends Object>`

## Field Summary

Fields
Modifier and Type
Field
Description
`private Map<Class<?>,Map<KeyType,ValueType>>`
`index`
Storage for index of class -> members.
`private Map<KeyType,ValueType>`
`map`
Storage for map members.
`private Set<Class<?>>`
`types`
Set of valid types for this map.

## Constructor Summary

Constructors
Constructor
Description
`ValueTypeIndexedMap()`
Constructor.
`ValueTypeIndexedMap(Collection<Class<?>> newTypes)`
Constructor.
`ValueTypeIndexedMap(Map<KeyType,ValueType> newMap, Collection<Class<?>> newTypes)`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`void`
`clear()`
`boolean`
`containsKey(Object key)`
`boolean`
`containsValue(Object value)`
`Set<Map.Entry<KeyType,ValueType>>`
`entrySet()`
`boolean`
`equals(Object obj)`
`ValueType`
`get(Object key)`
`Set<Class<?>>`
`getTypes()`
Get the value types that are indexed.
`int`
`hashCode()`
`boolean`
`isEmpty()`
`Set<KeyType>`
`keySet()`
`private boolean`
`matchType(Class<?> type, Object object)`
Check if the object is of the specified type, taking null into account as well.
`ValueType`
`put(KeyType key, ValueType value)`
`void`
`putAll(Map<? extends KeyType,? extends ValueType> t)`
`void`
`rebuildIndex()`
Rebuild internal index.
`ValueType`
`remove(Object key)`
`void`
`setTypes(Collection<Class<?>> newTypes)`
Set which value types are indexed.
`int`
`size()`
`<SubType extends ValueType>
Map<KeyType,SubType>`
`subMap(Class<SubType> type)`
Returns an unmodifiable map of the entries whose value is of the specified type.
`String`
`toString()`
`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`

## Field Details

### index

@Nonnull private Map<Class<?>,Map<KeyType,ValueType>> index
Storage for index of class -> members.

### map

@Nonnull private Map<KeyType,ValueType> map
Storage for map members.

### types

@Nonnull private Set<Class<?>> types
Set of valid types for this map.

## Constructor Details

### ValueTypeIndexedMap

public ValueTypeIndexedMap()
Constructor.

### ValueTypeIndexedMap

public ValueTypeIndexedMap(@Nonnull Map<KeyType,ValueType> newMap, @Nonnull Collection<Class<?>> newTypes)
Constructor.

Parameters:
  `newMap` - existing map to build from.
  `newTypes` - collection of value types to index

### ValueTypeIndexedMap

public ValueTypeIndexedMap(@Nonnull Collection<Class<?>> newTypes)
Constructor.

Parameters:
  `newTypes` - collection of value types to index

## Method Details

### clear

public void clear()

Specified by:
  `clear` in interface `Map<KeyType,ValueType>`

### containsKey

public boolean containsKey(Object key)

Specified by:
  `containsKey` in interface `Map<KeyType,ValueType>`

### containsValue

public boolean containsValue(Object value)

Specified by:
  `containsValue` in interface `Map<KeyType,ValueType>`

### entrySet

public Set<Map.Entry<KeyType,ValueType>> entrySet()

Specified by:
  `entrySet` in interface `Map<KeyType,ValueType>`

### get

public ValueType get(Object key)

Specified by:
  `get` in interface `Map<KeyType,ValueType>`

### getTypes

public Set<Class<?>> getTypes()
Get the value types that are indexed.

Returns:
  which value types are indexed

### isEmpty

public boolean isEmpty()

Specified by:
  `isEmpty` in interface `Map<KeyType,ValueType>`

### keySet

public Set<KeyType> keySet()

Specified by:
  `keySet` in interface `Map<KeyType,ValueType>`

### 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 for
  `object` - object to check
Returns:
  true if the object is of the specified type

### put

public ValueType put(KeyType key, ValueType value)

Specified by:
  `put` in interface `Map<KeyType,ValueType>`

### putAll

public void putAll(Map<? extends KeyType,? extends ValueType> t)

Specified by:
  `putAll` in interface `Map<KeyType,ValueType>`

### rebuildIndex

public void rebuildIndex()
Rebuild internal index.

### remove

public ValueType remove(Object key)

Specified by:
  `remove` in interface `Map<KeyType,ValueType>`

### setTypes

public void setTypes(@Nonnull Collection<Class<?>> newTypes)
Set which value types are indexed.

Parameters:
  `newTypes` - which value types are indexed

### size

public int size()

Specified by:
  `size` in interface `Map<KeyType,ValueType>`

### subMap

public <SubType extends ValueType> Map<KeyType,SubType> subMap(@Nullable 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()

Specified by:
  `hashCode` in interface `Map<KeyType,ValueType>`
Overrides:
  `hashCode` in class `Object`

### equals

public boolean equals(Object obj)

Specified by:
  `equals` in interface `Map<KeyType,ValueType>`
Overrides:
  `equals` in class `Object`

### toString

public String toString()

Overrides:
  `toString` in class `Object`

### values

public Collection<ValueType> values()

Specified by:
  `values` in interface `Map<KeyType,ValueType>`