Class LockableClassToInstanceMultiMap<B>
- java.lang.Object
-
- net.shibboleth.utilities.java.support.collection.ClassToInstanceMultiMap<B>
-
- net.shibboleth.utilities.java.support.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 ofClassToInstanceMultiMapwhich exposes a map-specific instance ofReadWriteLock.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 ReadWriteLockreadWriteLockThe map's read write lock.
-
Constructor Summary
Constructors Constructor Description LockableClassToInstanceMultiMap()Constructor.LockableClassToInstanceMultiMap(boolean isIndexingSupertypes)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclearWithLock()Convenience method which executes the like-named method from superclassClassToInstanceMultiMapunder a write lock.booleancontainsKeyWithLock(Class<?> key)Convenience method which executes the like-named method from superclassClassToInstanceMultiMapunder a read lock.booleancontainsValueWithLock(B value)Convenience method which executes the like-named method from superclassClassToInstanceMultiMapunder a read lock.ReadWriteLockgetReadWriteLock()Get the map-specific instance of theReadWriteLock.<T> List<T>getWithLock(Class<T> type)Convenience method which executes the like-named method from superclassClassToInstanceMultiMapunder a read lock.booleanisEmptyWithLock()Convenience method which executes the like-named method from superclassClassToInstanceMultiMapunder a read lock.Set<Class<?>>keysWithLock()Convenience method which executes the like-named method from superclassClassToInstanceMultiMapunder a read lock.voidputAllWithLock(Iterable<? extends B> newValues)Convenience method which executes the like-named method from superclassClassToInstanceMultiMapunder a write lock.voidputAllWithLock(ClassToInstanceMultiMap<? extends B> map)Convenience method which executes the like-named method from superclassClassToInstanceMultiMapunder a write lock.voidputWithLock(B value)Convenience method which executes the like-named method from superclassClassToInstanceMultiMapunder a write lock.voidremoveAllWithLock(Iterable<? extends B> removeValues)Convenience method which executes the like-named method from superclassClassToInstanceMultiMapunder a write lock.voidremoveAllWithLock(ClassToInstanceMultiMap<? extends B> map)Convenience method which executes the like-named method from superclassClassToInstanceMultiMapunder a write lock.voidremoveWithLock(B value)Convenience method which executes the like-named method from superclassClassToInstanceMultiMapunder a write lock.voidremoveWithLock(Class<?> type)Convenience method which executes the like-named method from superclassClassToInstanceMultiMapunder a write lock.Collection<? extends B>valuesWithLock()Convenience method which executes the like-named method from superclassClassToInstanceMultiMapunder a read lock.
-
-
-
Field Detail
-
readWriteLock
@Nonnull private final ReadWriteLock readWriteLock
The map's read write lock.
-
-
Constructor Detail
-
LockableClassToInstanceMultiMap
public LockableClassToInstanceMultiMap()
Constructor.
-
LockableClassToInstanceMultiMap
public LockableClassToInstanceMultiMap(boolean isIndexingSupertypes)
Constructor.- Parameters:
isIndexingSupertypes- indicates whether supertypes of a value should be indexed
-
-
Method Detail
-
getReadWriteLock
@Nonnull public ReadWriteLock getReadWriteLock()
Get the map-specific instance of theReadWriteLock.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 superclassClassToInstanceMultiMapunder a write lock.
-
containsKeyWithLock
public boolean containsKeyWithLock(@Nullable Class<?> key)Convenience method which executes the like-named method from superclassClassToInstanceMultiMapunder 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 superclassClassToInstanceMultiMapunder 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 @NonnullElements @Unmodifiable @Live public <T> List<T> getWithLock(@Nullable Class<T> type)
Convenience method which executes the like-named method from superclassClassToInstanceMultiMapunder 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 superclassClassToInstanceMultiMapunder a read lock.- Returns:
- true if this map contains no entries, false otherwise
-
keysWithLock
@Nonnull @NonnullElements @Unmodifiable @Live public Set<Class<?>> keysWithLock()
Convenience method which executes the like-named method from superclassClassToInstanceMultiMapunder 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 superclassClassToInstanceMultiMapunder a write lock.- Parameters:
value- value to be stored in the map
-
putAllWithLock
public void putAllWithLock(@Nullable @NonnullElements ClassToInstanceMultiMap<? extends B> map)
Convenience method which executes the like-named method from superclassClassToInstanceMultiMapunder a write lock.- Parameters:
map- map containing values to be added
-
putAllWithLock
public void putAllWithLock(@Nullable @NonnullElements Iterable<? extends B> newValues)
Convenience method which executes the like-named method from superclassClassToInstanceMultiMapunder 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 superclassClassToInstanceMultiMapunder 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 superclassClassToInstanceMultiMapunder a write lock.- Parameters:
type- the type of values to remove
-
removeAllWithLock
public void removeAllWithLock(@Nullable @NonnullElements ClassToInstanceMultiMap<? extends B> map)
Convenience method which executes the like-named method from superclassClassToInstanceMultiMapunder a write lock.- Parameters:
map- the map containing the values to remove
-
removeAllWithLock
public void removeAllWithLock(@Nullable @NonnullElements Iterable<? extends B> removeValues)
Convenience method which executes the like-named method from superclassClassToInstanceMultiMapunder a write lock.- Parameters:
removeValues- the values to remove
-
valuesWithLock
@Nonnull @NonnullElements @Unmodifiable @Live public Collection<? extends B> valuesWithLock()
Convenience method which executes the like-named method from superclassClassToInstanceMultiMapunder a read lock.- Returns:
- collection of values currently present in the map
-
-