Record Class Associations
java.lang.Object
java.lang.Record
io.axoniq.framework.workflow.runtime.association.Associations
public record Associations(ValueComparisonOperatorRegistry registry, Set<String> criteria)
extends Record
Immutable value object representing one or more association constraints used to correlate incoming events with a
waiting workflow step.
Each entry in criteria() is stored in the canonical serialized association DSL form
<source>:<path><operator><value>, for example payload:orderId=123. At runtime the workflow engine
evaluates these criteria against candidate events to determine whether an event belongs to the waiting step.
There are two primary construction styles:
- Programmatic construction using
associate(ValueRetriever, Matcher)orassociate(ValueRetriever, String, Object). This is the normal author-facing path used by workflow code. Start with one association and optionally extend it withand(ValueRetriever, Matcher)orand(ValueRetriever, String, Object). - Parsing canonical string representations using
parse(ValueComparisonOperatorRegistry, String...), which is useful for configuration-driven or persisted association definitions.
Typical usage from workflow code looks like this:
var associations = Associations.associate(
payloadProperty("orderId"),
Matcher("=", workflowOrderId)
).and(
payloadProperty("tenantId"),
Matcher("=", tenantId)
);
The DSL layer usually wraps this with friendlier helpers such as
associate(payloadProperty("orderId"), equalsTo(...)), but those helpers still produce this same
Associations value object underneath.
This type is immutable. Methods such as and(ValueRetriever, Matcher) return a new
Associations instance instead of mutating the existing one, which makes it safe to reuse base association
sets across workflow definitions.
- Since:
- 5.4.0
- Author:
- Simon Zambrovski
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordEncapsulates the value matcher containing of operator and the value. -
Constructor Summary
ConstructorsConstructorDescriptionAssociations(ValueComparisonOperatorRegistry registry, Set<String> criteria) Creates new associations. -
Method Summary
Modifier and TypeMethodDescriptionand(ValueRetriever retriever, Associations.Matcher matcher) Add additional association to existing ones.and(ValueRetriever retriever, String operator, Object value) Add additional associations to existing ones.static Associationsassociate(ValueRetriever retriever, Associations.Matcher matcher) Create associations providing the first one.static Associationsassociate(ValueRetriever retriever, String operator, Object value) Create new associations providing the first one.criteria()Returns the value of thecriteriarecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.static Associationsparse(ValueComparisonOperatorRegistry registry, String... associations) Creates new associations parsing string representations.registry()Returns the value of theregistryrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
Associations
Creates new associations.- Parameters:
registry- operator registry to usecriteria- association criteria
-
-
Method Details
-
associate
Create new associations providing the first one.- Parameters:
retriever- value retriever, seePayloadPropertyValueRetriever.payloadProperty(String)for example.operator- operator for value comparisonvalue- right side of comparison- Returns:
- an association upon which can be build further, for fluent interface.
-
associate
Create associations providing the first one.- Parameters:
retriever- value retriever, seePayloadPropertyValueRetriever.payloadProperty(String)for example.matcher- variable matcher, seeAssociations.Matcherfor example.- Returns:
- an association upon which can be build further, for fluent interface
-
parse
Creates new associations parsing string representations.- Parameters:
registry- registry to useassociations- associations to parse- Returns:
- associations instance
-
and
Add additional associations to existing ones.- Parameters:
retriever- value retriever for the left side of the comparison, seePayloadPropertyValueRetriever.payloadProperty(String)for example.operator- operator for value comparisonvalue- right side of comparison- Returns:
- new associations containing old associations and new one
-
and
Add additional association to existing ones.- Parameters:
retriever- value retriever for the left side of the comparison, seePayloadPropertyValueRetriever.payloadProperty(String)for example.matcher- value matcher including operator and value for comparison- Returns:
- new associations containing old associations and new one
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
registry
Returns the value of theregistryrecord component.- Returns:
- the value of the
registryrecord component
-
criteria
Returns the value of thecriteriarecord component.- Returns:
- the value of the
criteriarecord component
-