Package org.alfresco.repo.transaction
Class TransactionalResourceHelper
java.lang.Object
org.alfresco.repo.transaction.TransactionalResourceHelper
Helper class that will look up or create transactional resources. This shortcuts some of the "if not existing, then create" code.
- Since:
- 3.2
- Author:
- Derek Hulley
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic final intdecrementCount(Object resourceKey, boolean allowNegative) Decrement a count value for a named keystatic final intGet the current count value for a named keystatic final <V> List<V>Support method to retrieve or create and bind a ArrayList to the current transaction.static final <K,V> Map<K, V> Support method to retrieve or create and bind a HashMap to the current transaction.static final <V> Set<V>Support method to retrieve or create and bind a HashSet to the current transaction.static final <V> TreeSet<V>getTreeSet(Object resourceKey) Support method to retrieve or create and bind a TreeSet to the current transaction.static final intincrementCount(Object resourceKey) Increment a count value for named keystatic final booleanisResourcePresent(Object resourceKey) Support method to determine if there is already a resource associated with the given key.static final voidresetCount(Object resourceKey) Reset the current count value for a named key.
-
Constructor Details
-
TransactionalResourceHelper
public TransactionalResourceHelper()
-
-
Method Details
-
getCount
Get the current count value for a named key- Parameters:
resourceKey- the key to count against- Returns:
- the current value for the named key
-
resetCount
Reset the current count value for a named key. After this operation, the effective value will be 0.- Parameters:
resourceKey- the key to count against
-
incrementCount
Increment a count value for named key- Parameters:
resourceKey- the key to count against- Returns:
- the newly-incremented value
-
decrementCount
Decrement a count value for a named key- Parameters:
resourceKey- the key to count againstallowNegative- true to allow negative values otherwise zero will be the floor- Returns:
- the newly-decremented value (negative, if allowed)
-
isResourcePresent
Support method to determine if there is already a resource associated with the given key. This method allows quick conditional checking of the key without building a new collection.- Parameters:
resourceKey- the key of the resource to check- Returns:
- true if a resource is already present at the key
-
getMap
Support method to retrieve or create and bind a HashMap to the current transaction.- Type Parameters:
K- the map key typeV- the map value type- Parameters:
resourceKey- the key under which the resource will be stored- Returns:
- Returns an previously-bound Map or else a newly-bound HashMap
-
getSet
Support method to retrieve or create and bind a HashSet to the current transaction.- Type Parameters:
V- the set value type- Parameters:
resourceKey- the key under which the resource will be stored- Returns:
- Returns an previously-bound Set or else a newly-bound HashSet
-
getTreeSet
Support method to retrieve or create and bind a TreeSet to the current transaction.- Type Parameters:
V- the set value type- Parameters:
resourceKey- the key under which the resource will be stored- Returns:
- Returns an previously-bound TreeSet or else a newly-bound TreeSet
-
getList
Support method to retrieve or create and bind a ArrayList to the current transaction.- Type Parameters:
V- the list value type- Parameters:
resourceKey- the key under which the resource will be stored- Returns:
- Returns an previously-bound List or else a newly-bound ArrayList
-