Class AssociationValueMap
java.lang.Object
org.axonframework.modelling.saga.repository.AssociationValueMap
In-memory storage for AssociationValue to Saga mappings. A single AssociationValue can map to several Sagas, and a
single Saga can be mapped by several AssociationValues.
Note that this "map" does not implement the Map interface. This is mainly due to the specific nature and intent of
this implementation. For example, the Map interface does not allow a single key to point to more than one value.
This implementation is thread safe and has an expected average time cost of
log(n).- Since:
- 0.7
- Author:
- Allard Buijze
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(AssociationValue associationValue, String sagaType, String sagaIdentifier) Adds an association between the givenassociationValueandsagaIdentifier.voidclear()Clears all the associations.findSagas(String sagaType, AssociationValue associationValue) Returns the identifiers of the Sagas that have been associated with the givenassociationValue.booleanisEmpty()Indicates whether any elements are contained within this map.voidremove(AssociationValue associationValue, String sagaType, String sagaIdentifier) Removes an association between the givenassociationValueandsagaIdentifier.intsize()Returns an approximation of the size of this map.
-
Constructor Details
-
AssociationValueMap
public AssociationValueMap()Initializes a new and empty AssociationValueMap.
-
-
Method Details
-
findSagas
Returns the identifiers of the Sagas that have been associated with the givenassociationValue.- Parameters:
sagaType- The type of the associated SagaassociationValue- The associationValue to find Sagas for- Returns:
- A set of Saga identifiers
-
add
Adds an association between the givenassociationValueandsagaIdentifier.- Parameters:
associationValue- The association value associated with the SagasagaType- The type of the associated SagasagaIdentifier- The identifier of the associated Saga
-
remove
Removes an association between the givenassociationValueandsagaIdentifier.- Parameters:
associationValue- The association value associated with the SagasagaType- The type of the associated SagasagaIdentifier- The identifier of the associated Saga
-
clear
public void clear()Clears all the associations. -
isEmpty
public boolean isEmpty()Indicates whether any elements are contained within this map.- Returns:
trueif this Map is empty,falseif it contains any associations.
-
size
public int size()Returns an approximation of the size of this map. Due to the concurrent nature of this map, size cannot return an accurate value. This is not a constant-time operation. The backing store of this map requires full traversal of elements to calculate this size.- Returns:
- an approximation of the number of elements in this map
-