Package net.shibboleth.shared.collection

# Class LockableClassToInstanceMultiMap<B>

java.lang.Object
net.shibboleth.shared.collection.ClassToInstanceMultiMap<B>
net.shibboleth.shared.collection.LockableClassToInstanceMultiMap<B>

Type Parameters:
  `B` - a bound for the types of values in the map

public class LockableClassToInstanceMultiMap<B> extends ClassToInstanceMultiMap<B>
A specialization of `ClassToInstanceMultiMap` which exposes a map-specific instance of `ReadWriteLock`.

Callers of the map are generally responsible for explicitly locking and unlocking for reading and writing, based on application use cases and concurrency requirements. For simple single-statement atomic operations, convenience methods are supplied which execute the corresponding superclass operation under the read or write lock, as appropriate.

## Field Summary

Fields
Modifier and Type
Field
Description
`private final ReadWriteLock`
`readWriteLock`
The map's read write lock.

## Constructor Summary

Constructors
Constructor
Description
`LockableClassToInstanceMultiMap()`
Constructor.
`LockableClassToInstanceMultiMap(boolean isIndexingSupertypes)`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`void`
`clearWithLock()`
Convenience method which executes the like-named method from superclass `ClassToInstanceMultiMap` under a write lock.
`boolean`
`containsKeyWithLock(Class<?> key)`
Convenience method which executes the like-named method from superclass `ClassToInstanceMultiMap` under a read lock.
`boolean`
`containsValueWithLock(B value)`
Convenience method which executes the like-named method from superclass `ClassToInstanceMultiMap` under a read lock.
`ReadWriteLock`
`getReadWriteLock()`
Get the map-specific instance of the `ReadWriteLock`.
`<T> List<T>`
`getWithLock(Class<T> type)`
Convenience method which executes the like-named method from superclass `ClassToInstanceMultiMap` under a read lock.
`boolean`
`isEmptyWithLock()`
Convenience method which executes the like-named method from superclass `ClassToInstanceMultiMap` under a read lock.
`Set<Class<?>>`
`keysWithLock()`
Convenience method which executes the like-named method from superclass `ClassToInstanceMultiMap` under a read lock.
`void`
`putAllWithLock(Iterable<? extends B> newValues)`
Convenience method which executes the like-named method from superclass `ClassToInstanceMultiMap` under a write lock.
`void`
`putAllWithLock(ClassToInstanceMultiMap<? extends B> map)`
Convenience method which executes the like-named method from superclass `ClassToInstanceMultiMap` under a write lock.
`void`
`putWithLock(B value)`
Convenience method which executes the like-named method from superclass `ClassToInstanceMultiMap` under a write lock.
`void`
`removeAllWithLock(Iterable<? extends B> removeValues)`
Convenience method which executes the like-named method from superclass `ClassToInstanceMultiMap` under a write lock.
`void`
`removeAllWithLock(ClassToInstanceMultiMap<? extends B> map)`
Convenience method which executes the like-named method from superclass `ClassToInstanceMultiMap` under a write lock.
`void`
`removeWithLock(B value)`
Convenience method which executes the like-named method from superclass `ClassToInstanceMultiMap` under a write lock.
`void`
`removeWithLock(Class<?> type)`
Convenience method which executes the like-named method from superclass `ClassToInstanceMultiMap` under a write lock.
`Collection<? extends B>`
`valuesWithLock()`
Convenience method which executes the like-named method from superclass `ClassToInstanceMultiMap` under a read lock.

### Methods inherited from class net.shibboleth.shared.collection.ClassToInstanceMultiMap

`clear, containsKey, containsValue, equals, get, hashCode, isEmpty, keys, put, putAll, putAll, remove, remove, removeAll, removeAll, values`

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### readWriteLock

@Nonnull private final ReadWriteLock readWriteLock
The map's read write lock.

## Constructor Details

### LockableClassToInstanceMultiMap

public LockableClassToInstanceMultiMap()
Constructor.

### LockableClassToInstanceMultiMap

public LockableClassToInstanceMultiMap(boolean isIndexingSupertypes)
Constructor.

Parameters:
  `isIndexingSupertypes` - indicates whether supertypes of a value should be indexed

## Method Details

### getReadWriteLock

@Nonnull public ReadWriteLock getReadWriteLock()
Get the map-specific instance of the `ReadWriteLock`.

Callers of the map are responsible for explicitly locking (and unlocking) for reading and/or writing, based on application use cases.

Returns:
  Returns the rwlock.

### clearWithLock

public void clearWithLock()
Convenience method which executes the like-named method from superclass `ClassToInstanceMultiMap` under a write lock.

### containsKeyWithLock

public boolean containsKeyWithLock(@Nullable Class<?> key)
Convenience method which executes the like-named method from superclass `ClassToInstanceMultiMap` under a read lock.

Parameters:
  `key` - key to check for in the map
Returns:
  true if the map contains a mapping for the specified key

### containsValueWithLock

public boolean containsValueWithLock(@Nullable B value)
Convenience method which executes the like-named method from superclass `ClassToInstanceMultiMap` under a read lock.

Parameters:
  `value` - value to check for in this map
Returns:
  true if the map contains a mapping to the specified value

### getWithLock

@Nonnull @Unmodifiable @Live public <T> List<T> getWithLock(@Nullable Class<T> type)
Convenience method which executes the like-named method from superclass `ClassToInstanceMultiMap` under a read lock.

Type Parameters:
  `T` - type identifier
Parameters:
  `type` - map key
Returns:
  instances mapped to the given type or an empty list

### isEmptyWithLock

public boolean isEmptyWithLock()
Convenience method which executes the like-named method from superclass `ClassToInstanceMultiMap` under a read lock.

Returns:
  true if this map contains no entries, false otherwise

### keysWithLock

@Nonnull @Unmodifiable @Live public Set<Class<?>> keysWithLock()
Convenience method which executes the like-named method from superclass `ClassToInstanceMultiMap` under a read lock.

Returns:
  set of keys contained in this map

### putWithLock

public void putWithLock(@Nonnull B value)
Convenience method which executes the like-named method from superclass `ClassToInstanceMultiMap` under a write lock.

Parameters:
  `value` - value to be stored in the map

### putAllWithLock

public void putAllWithLock(@Nullable ClassToInstanceMultiMap<? extends B> map)
Convenience method which executes the like-named method from superclass `ClassToInstanceMultiMap` under a write lock.

Parameters:
  `map` - map containing values to be added

### putAllWithLock

public void putAllWithLock(@Nullable Iterable<? extends B> newValues)
Convenience method which executes the like-named method from superclass `ClassToInstanceMultiMap` under a write lock.

Parameters:
  `newValues` - values to be added

### removeWithLock

public void removeWithLock(@Nonnull B value)
Convenience method which executes the like-named method from superclass `ClassToInstanceMultiMap` under a write lock.

Parameters:
  `value` - the value to remove

### removeWithLock

public void removeWithLock(@Nullable Class<?> type)
Convenience method which executes the like-named method from superclass `ClassToInstanceMultiMap` under a write lock.

Parameters:
  `type` - the type of values to remove

### removeAllWithLock

public void removeAllWithLock(@Nullable ClassToInstanceMultiMap<? extends B> map)
Convenience method which executes the like-named method from superclass `ClassToInstanceMultiMap` under a write lock.

Parameters:
  `map` - the map containing the values to remove

### removeAllWithLock

public void removeAllWithLock(@Nullable Iterable<? extends B> removeValues)
Convenience method which executes the like-named method from superclass `ClassToInstanceMultiMap` under a write lock.

Parameters:
  `removeValues` - the values to remove

### valuesWithLock

@Nonnull @Unmodifiable @Live public Collection<? extends B> valuesWithLock()
Convenience method which executes the like-named method from superclass `ClassToInstanceMultiMap` under a read lock.

Returns:
  collection of values currently present in the map