public final class LockedContainerHelper extends Object
| Modifier and Type | Method and Description |
|---|---|
static <T> boolean |
add(Collection<T> aObjects,
T aObject,
ReentrantReadWriteLock aLock)
Performs a simple add operation of the passed collection using the passed
object, locking the operation using the passed lock
|
static <T> boolean |
addAll(Collection<T> aObjects,
Collection<T> aObjectsToAdd,
ReentrantReadWriteLock aLock)
Performs a simple addAll operation of the passed collection using the
passed objects, locking the operation using the passed lock
|
static <T> void |
clear(Collection<T> aObjects,
ReentrantReadWriteLock aLock)
Performs a simple clear operation on the passed collection, locking the
operation using the passed lock
|
static <K,V> void |
clear(Map<K,V> aObjects,
ReentrantReadWriteLock aLock)
Performs a simple clear operation on the passed map, locking the operation
using the passed lock
|
static <T> boolean |
contains(Collection<T> aCollection,
T aItem,
ReentrantReadWriteLock aLock)
Checks if the passed item is contained in the passed collection in a thread
safe manner
|
static <T> boolean |
containsAll(Collection<T> aCollection,
Collection<T> aItems,
ReentrantReadWriteLock aLock)
Checks if all the passed items is contained in the passed collection in a
thread safe manner
|
static <T> T |
get(List<T> aObjects,
int nIndex,
ReentrantReadWriteLock aLock)
Returns the element with the specified index from the passed list in a read
locked context
|
static <K,T> T |
getByKey(K aKey,
Map<K,T> aObjectsByKey,
ReentrantReadWriteLock aLock)
Looks for the map entry with the passed key and return the corresponding
object
|
static <K,T,R> R |
getByKeyCasted(K aKey,
Map<K,T> aObjectsByKey,
ReentrantReadWriteLock aLock)
Performs a lookup using
getByKey(Object, Map, ReentrantReadWriteLock) returning the result
casted according to the requested type |
static <T> Collection<T> |
getCollection(Collection<T> aObjects,
ReentrantReadWriteLock aLock)
Returns a copy of the passed container performed in a read locked context
|
static <T> T |
getFirst(Collection<T> aObjects,
ReentrantReadWriteLock aLock)
returns the first element of the passed collection, locking the operation
using the passed lock
|
static <T> T |
getFirstValue(Map<?,T> aObjects,
ReentrantReadWriteLock aLock)
returns the value of the first entry in the passed map, locking the
operation using the passed lock
|
static Set<String> |
getIDs(Collection<? extends IHasID<String>> aElements,
ReentrantReadWriteLock aLock)
Iterates all passed objects and collect their IDs
|
static <K,V> Collection<K> |
getKeys(Map<K,V> aObjects,
ReentrantReadWriteLock aLock)
Returns a copy of the keys in the passed map performed in a read locked
context
|
static <T> List<T> |
getList(Collection<T> aObjects,
ReentrantReadWriteLock aLock)
Returns a copy of the passed container as a list performed in a read locked
context
|
static <K,V> Map<K,V> |
getMap(Map<K,V> aObjects,
ReentrantReadWriteLock aLock)
Returns a copy of the passed map in a read locked context
|
static <K,T> Set<T> |
getMultiMapEntry(AbstractMultiHashMapSetBased<K,T> aMap,
K aKey,
ReentrantReadWriteLock aLock)
Returns a copy of the entry in the passed multi-map corresponding to the
passed key, performing the access in a read locked context
|
static <T> Set<T> |
getSet(Set<T> aObjects,
ReentrantReadWriteLock aLock)
Returns a copy of the passed container performed in a read locked context
|
static <T> int |
getSize(Collection<T> aObjects,
ReentrantReadWriteLock aLock)
returns the size of the passed collection, locking the operation using the
passed lock
|
static <K,V> int |
getSize(Map<K,V> aObjects,
ReentrantReadWriteLock aLock)
returns the size of the passed map, locking the operation using the passed
lock
|
static <T> Stack<T> |
getStack(Stack<T> aObjects,
ReentrantReadWriteLock aLock)
Returns a mutable copy of the passed stack performed in a read locked
context
|
static <K,V> Set<V> |
getValues(Map<K,V> aObjects,
ReentrantReadWriteLock aLock)
Returns a copy of the values in the passed map performed in a read locked
context
|
static <T> boolean |
isEmpty(Collection<T> aObjects,
ReentrantReadWriteLock aLock)
Performs a simple check on the passed collection to see if it is empty,
locking the operation using the passed lock
|
static <K,V> boolean |
isEmpty(Map<K,V> aObjects,
ReentrantReadWriteLock aLock)
Performs a simple check on the passed map to see if it is empty, locking
the operation using the passed lock
|
static <K,V> V |
put(Map<K,V> aMap,
K aKey,
V aValue,
ReentrantReadWriteLock aLock)
Performs a simple put action on a map, locking the operation using the
passed lock
|
static <K,V> void |
putAll(Map<K,V> aMap,
Map<K,V> aEntries,
ReentrantReadWriteLock aLock)
Tries to put all entries in the seconds map into the first map
|
static <T> boolean |
remove(Collection<T> aObjects,
T aObject,
ReentrantReadWriteLock aLock)
Performs a simple remove operation of the passed collection using the
passed object, locking the operation using the passed lock
|
static <K,V> V |
remove(Map<K,V> aMap,
K aKey,
ReentrantReadWriteLock aLock)
Performs a simple remove action on a map, locking the operation using the
passed lock
|
static <T> boolean |
removeAll(Collection<T> aObjects,
Collection<T> aObjectsToRemove,
ReentrantReadWriteLock aLock)
Performs a simple removeAll operation of the passed collection using the
passed objects, locking the operation using the passed lock
|
@Nullable public static <K,T> T getByKey(K aKey, @Nonnull Map<K,T> aObjectsByKey, @Nonnull ReentrantReadWriteLock aLock)
aKey - The key of the object (e.g. ID or name)aObjectsByKey - A map containing all available objects mapped to their keyaLock - The monitor to usenull if not foundpublic static <K,T,R> R getByKeyCasted(K aKey,
@Nonnull
Map<K,T> aObjectsByKey,
@Nonnull
ReentrantReadWriteLock aLock)
getByKey(Object, Map, ReentrantReadWriteLock) returning the result
casted according to the requested typeaKey - The key of the object (e.g. ID or name)aObjectsByKey - A map containing all available objects mapped to their keyaLock - The monitor to usenull if not found@ReturnsMutableCopy public static <T> Collection<T> getCollection(@Nonnull Collection<T> aObjects, @Nonnull ReentrantReadWriteLock aLock)
aObjects - The container to copyaLock - The lock to use@ReturnsMutableCopy public static <T> List<T> getList(@Nonnull Collection<T> aObjects, @Nonnull ReentrantReadWriteLock aLock)
aObjects - The container to copyaLock - The lock to use@ReturnsMutableCopy public static <K,V> Map<K,V> getMap(@Nonnull Map<K,V> aObjects, @Nonnull ReentrantReadWriteLock aLock)
aObjects - The map to copyaLock - The lock to usepublic static <T> T get(@Nonnull List<T> aObjects, int nIndex, @Nonnull ReentrantReadWriteLock aLock)
aObjects - The list to accessnIndex - aLock - The lock to use@ReturnsMutableCopy public static <K,V> Set<V> getValues(@Nonnull Map<K,V> aObjects, @Nonnull ReentrantReadWriteLock aLock)
aObjects - The map containing the values to retrieveaLock - The lock to use@ReturnsMutableCopy public static <K,V> Collection<K> getKeys(@Nonnull Map<K,V> aObjects, @Nonnull ReentrantReadWriteLock aLock)
aObjects - The map containing the values to retrieveaLock - The lock to use@ReturnsMutableCopy @Nonnull public static <K,T> Set<T> getMultiMapEntry(@Nonnull AbstractMultiHashMapSetBased<K,T> aMap, @Nonnull K aKey, @Nonnull ReentrantReadWriteLock aLock)
aMap - The container to copyaKey - The map entry keyaLock - The lock to use@ReturnsMutableCopy public static <T> Set<T> getSet(@Nonnull Set<T> aObjects, @Nonnull ReentrantReadWriteLock aLock)
aObjects - The container to copyaLock - The lock to use@Nonnull @ReturnsMutableCopy public static <T> Stack<T> getStack(@Nonnull Stack<T> aObjects, @Nonnull ReentrantReadWriteLock aLock)
aObjects - the stack to copyaLock - the lock to usepublic static <T> boolean remove(@Nonnull Collection<T> aObjects, @Nonnull T aObject, @Nonnull ReentrantReadWriteLock aLock)
aObjects - aObject - aLock - public static <T> boolean contains(@Nonnull Collection<T> aCollection, @Nonnull T aItem, @Nonnull ReentrantReadWriteLock aLock)
aCollection - aItem - aLock - public static <T> boolean containsAll(@Nullable Collection<T> aCollection, @Nonnull Collection<T> aItems, @Nonnull ReentrantReadWriteLock aLock)
aCollection - aItems - aLock - public static <T> void clear(@Nonnull Collection<T> aObjects, @Nonnull ReentrantReadWriteLock aLock)
aObjects - aLock - public static <T> boolean add(@Nonnull Collection<T> aObjects, @Nonnull T aObject, @Nonnull ReentrantReadWriteLock aLock)
aObjects - aObject - aLock - public static <T> boolean addAll(@Nonnull Collection<T> aObjects, @Nullable Collection<T> aObjectsToAdd, @Nonnull ReentrantReadWriteLock aLock)
aObjects - aObjectsToAdd - aLock - public static <T> boolean removeAll(@Nonnull Collection<T> aObjects, @Nullable Collection<T> aObjectsToRemove, @Nonnull ReentrantReadWriteLock aLock)
aObjects - aObjectsToRemove - aLock - public static <K,V> V put(@Nonnull Map<K,V> aMap, @Nonnull K aKey, @Nonnull V aValue, @Nonnull ReentrantReadWriteLock aLock)
aMap - aKey - aValue - aLock - public static <K,V> void putAll(@Nonnull Map<K,V> aMap, @Nullable Map<K,V> aEntries, @Nonnull ReentrantReadWriteLock aLock)
aMap - The main map that should be modifiedaEntries - A map containing the entries that should be put to the first map,
may be nullaLock - public static <K,V> V remove(@Nonnull Map<K,V> aMap, @Nonnull K aKey, @Nonnull ReentrantReadWriteLock aLock)
aMap - aKey - aLock - public static <K,V> void clear(@Nonnull Map<K,V> aObjects, @Nonnull ReentrantReadWriteLock aLock)
aObjects - aLock - public static <T> boolean isEmpty(@Nonnull Collection<T> aObjects, @Nonnull ReentrantReadWriteLock aLock)
aObjects - aLock - public static <K,V> boolean isEmpty(@Nonnull Map<K,V> aObjects, @Nonnull ReentrantReadWriteLock aLock)
aObjects - aLock - public static <K,V> int getSize(@Nonnull Map<K,V> aObjects, @Nonnull ReentrantReadWriteLock aLock)
aObjects - aLock - public static <T> int getSize(@Nonnull Collection<T> aObjects, @Nonnull ReentrantReadWriteLock aLock)
aObjects - aLock - public static <T> T getFirst(@Nonnull Collection<T> aObjects, @Nonnull ReentrantReadWriteLock aLock)
aObjects - aLock - null if
emptypublic static <T> T getFirstValue(@Nonnull Map<?,T> aObjects, @Nonnull ReentrantReadWriteLock aLock)
aObjects - aLock - null if empty@Nonnull public static Set<String> getIDs(@Nonnull Collection<? extends IHasID<String>> aElements, @Nonnull ReentrantReadWriteLock aLock)
aElements - Objects for which to collect the IDs, must not be nullaLock - The lock to useCopyright © 2006–2015 phloc systems. All rights reserved.