Class AssociationValueMap

java.lang.Object
org.axonframework.modelling.saga.repository.AssociationValueMap

public class AssociationValueMap extends Object
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 Details

    • AssociationValueMap

      public AssociationValueMap()
      Initializes a new and empty AssociationValueMap.
  • Method Details

    • findSagas

      public Set<String> findSagas(String sagaType, AssociationValue associationValue)
      Returns the identifiers of the Sagas that have been associated with the given associationValue.
      Parameters:
      sagaType - The type of the associated Saga
      associationValue - The associationValue to find Sagas for
      Returns:
      A set of Saga identifiers
    • add

      public void add(AssociationValue associationValue, String sagaType, String sagaIdentifier)
      Adds an association between the given associationValue and sagaIdentifier.
      Parameters:
      associationValue - The association value associated with the Saga
      sagaType - The type of the associated Saga
      sagaIdentifier - The identifier of the associated Saga
    • remove

      public void remove(AssociationValue associationValue, String sagaType, String sagaIdentifier)
      Removes an association between the given associationValue and sagaIdentifier.
      Parameters:
      associationValue - The association value associated with the Saga
      sagaType - The type of the associated Saga
      sagaIdentifier - 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:
      true if this Map is empty, false if 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