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
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 -
Constructor Summary
ConstructorsConstructorDescriptionConstructor.LockableClassToInstanceMultiMap(boolean isIndexingSupertypes) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidConvenience 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.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.booleanConvenience method which executes the like-named method from superclassClassToInstanceMultiMapunder a read lock.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>Convenience method which executes the like-named method from superclassClassToInstanceMultiMapunder a read lock.
-
Field Details
-
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
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
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
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
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
Convenience method which executes the like-named method from superclassClassToInstanceMultiMapunder a read lock.- Returns:
- set of keys contained in this map
-
putWithLock
Convenience method which executes the like-named method from superclassClassToInstanceMultiMapunder a write lock.- Parameters:
value- value to be stored in the map
-
putAllWithLock
Convenience method which executes the like-named method from superclassClassToInstanceMultiMapunder a write lock.- Parameters:
newValues- values to be added
-
removeWithLock
Convenience method which executes the like-named method from superclassClassToInstanceMultiMapunder a write lock.- Parameters:
value- the value to remove
-
removeWithLock
Convenience method which executes the like-named method from superclassClassToInstanceMultiMapunder a write lock.- Parameters:
type- the type of values to remove
-
removeAllWithLock
Convenience method which executes the like-named method from superclassClassToInstanceMultiMapunder a write lock.- Parameters:
removeValues- the values to remove
-
valuesWithLock
Convenience method which executes the like-named method from superclassClassToInstanceMultiMapunder a read lock.- Returns:
- collection of values currently present in the map
-