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
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 TypeMethodDescriptionvoid
Convenience method which executes the like-named method from superclassClassToInstanceMultiMap
under a write lock.boolean
containsKeyWithLock
(Class<?> key) Convenience method which executes the like-named method from superclassClassToInstanceMultiMap
under a read lock.boolean
containsValueWithLock
(B value) Convenience method which executes the like-named method from superclassClassToInstanceMultiMap
under 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 superclassClassToInstanceMultiMap
under a read lock.boolean
Convenience method which executes the like-named method from superclassClassToInstanceMultiMap
under a read lock.Convenience method which executes the like-named method from superclassClassToInstanceMultiMap
under a read lock.void
putAllWithLock
(Iterable<? extends B> newValues) Convenience method which executes the like-named method from superclassClassToInstanceMultiMap
under a write lock.void
putAllWithLock
(ClassToInstanceMultiMap<? extends B> map) Convenience method which executes the like-named method from superclassClassToInstanceMultiMap
under a write lock.void
putWithLock
(B value) Convenience method which executes the like-named method from superclassClassToInstanceMultiMap
under a write lock.void
removeAllWithLock
(Iterable<? extends B> removeValues) Convenience method which executes the like-named method from superclassClassToInstanceMultiMap
under a write lock.void
removeAllWithLock
(ClassToInstanceMultiMap<? extends B> map) Convenience method which executes the like-named method from superclassClassToInstanceMultiMap
under a write lock.void
removeWithLock
(B value) Convenience method which executes the like-named method from superclassClassToInstanceMultiMap
under a write lock.void
removeWithLock
(Class<?> type) Convenience method which executes the like-named method from superclassClassToInstanceMultiMap
under a write lock.Collection<? extends B>
Convenience method which executes the like-named method from superclassClassToInstanceMultiMap
under 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 superclassClassToInstanceMultiMap
under a write lock. -
containsKeyWithLock
Convenience method which executes the like-named method from superclassClassToInstanceMultiMap
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
Convenience method which executes the like-named method from superclassClassToInstanceMultiMap
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 @NonnullElements @Unmodifiable @Live public <T> List<T> getWithLock(@Nullable Class<T> type) Convenience method which executes the like-named method from superclassClassToInstanceMultiMap
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 superclassClassToInstanceMultiMap
under a read lock.- Returns:
- true if this map contains no entries, false otherwise
-
keysWithLock
Convenience method which executes the like-named method from superclassClassToInstanceMultiMap
under a read lock.- Returns:
- set of keys contained in this map
-
putWithLock
Convenience method which executes the like-named method from superclassClassToInstanceMultiMap
under a write lock.- Parameters:
value
- value to be stored in the map
-
putAllWithLock
Convenience method which executes the like-named method from superclassClassToInstanceMultiMap
under a write lock.- Parameters:
map
- map containing values to be added
-
putAllWithLock
Convenience method which executes the like-named method from superclassClassToInstanceMultiMap
under a write lock.- Parameters:
newValues
- values to be added
-
removeWithLock
Convenience method which executes the like-named method from superclassClassToInstanceMultiMap
under a write lock.- Parameters:
value
- the value to remove
-
removeWithLock
Convenience method which executes the like-named method from superclassClassToInstanceMultiMap
under a write lock.- Parameters:
type
- the type of values to remove
-
removeAllWithLock
Convenience method which executes the like-named method from superclassClassToInstanceMultiMap
under a write lock.- Parameters:
map
- the map containing the values to remove
-
removeAllWithLock
Convenience method which executes the like-named method from superclassClassToInstanceMultiMap
under a write lock.- Parameters:
removeValues
- the values to remove
-
valuesWithLock
Convenience method which executes the like-named method from superclassClassToInstanceMultiMap
under a read lock.- Returns:
- collection of values currently present in the map
-