Class EntityParameterResolver
java.lang.Object
io.fluxcapacitor.javaclient.modeling.EntityParameterResolver
- All Implemented Interfaces:
ParameterResolver<Object>
Resolves handler method parameters that reference an
Entity
or the entity's value.
This resolver supports parameters of either Entity<T>
or the entity's actual type T
.
It will traverse the hierarchy of parent-child relationships between entities (if any) to find the closest match.
Resolution logic supports both HasEntity
and HasMessage
sources:
- If the input implements
HasEntity
, the existing entity is used. - If the input implements
HasMessage
, the resolver attempts to extract the aggregate type and ID, then loads the entity from the platform usingFluxCapacitor#loadEntity
.
The entity is only resolved if:
- The parameter type is assignable from the resolved entity type (or the
Entity<T>
type). - Or, the entity has a parent matching the required parameter type.
This resolver determines handler method specificity and can thus be used in disambiguation when multiple handler methods are present in the same target class.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
Indicates that this resolver contributes to disambiguating handler methods when multiple handlers are present in the same target class.protected Entity
<?> getMatchingEntity
(Object input, Parameter parameter) Attempts to retrieve anEntity
instance matching the given method parameter.protected boolean
isAssignable
(Parameter parameter, Entity<?> entity) Returnstrue
if the entity or any of its parents match the expected parameter type.protected boolean
Returnstrue
if the entity or any of its parents match the expected parameter type.boolean
matches
(Parameter parameter, Annotation methodAnnotation, Object input) Determines whether the parameter can be resolved from the given input.protected Supplier
<?> Returns aSupplier
that returns the entity if the entity or any of its parents match the expected parameter type.resolve
(Parameter parameter, Annotation methodAnnotation) Provides aSupplier
that returns the matching entity or its value for the given parameter.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.fluxcapacitor.common.handling.ParameterResolver
filterMessage
-
Constructor Details
-
EntityParameterResolver
public EntityParameterResolver()
-
-
Method Details
-
resolve
Provides aSupplier
that returns the matching entity or its value for the given parameter. Will recursively traverse parent entities if needed.- Specified by:
resolve
in interfaceParameterResolver<Object>
- Parameters:
parameter
- the parameter for which a value must be injectedmethodAnnotation
- the annotation on the handler method (unused here)- Returns:
- a function that supplies the resolved value
-
matches
Determines whether the parameter can be resolved from the given input. The match succeeds if a suitable entity or value can be found in the message or entity context.- Specified by:
matches
in interfaceParameterResolver<Object>
- Parameters:
parameter
- the method parametermethodAnnotation
- the annotation on the handler method (unused here)input
- the handler input (e.g.,DeserializingMessage
orHasEntity
)- Returns:
- true if the parameter can be resolved from the input, false otherwise
-
getMatchingEntity
Attempts to retrieve anEntity
instance matching the given method parameter.The search is performed on:
HasEntity
input types (directly returning the contained entity)HasMessage
input types (by extracting aggregate metadata and loading the entity)
- Parameters:
input
- the message or entity contextparameter
- the method parameter being resolved- Returns:
- the matching
Entity
ornull
if not resolvable
-
matches
Returnstrue
if the entity or any of its parents match the expected parameter type. -
resolve
Returns aSupplier
that returns the entity if the entity or any of its parents match the expected parameter type. -
isAssignable
Returnstrue
if the entity or any of its parents match the expected parameter type. -
determinesSpecificity
public boolean determinesSpecificity()Indicates that this resolver contributes to disambiguating handler methods when multiple handlers are present in the same target class.This is useful when more than one method matches a message, and the framework must decide which method is more specific. If this returns
true
, the resolver's presence and compatibility with the parameter may influence which handler is selected.- Specified by:
determinesSpecificity
in interfaceParameterResolver<Object>
- Returns:
- true, signaling that this resolver helps determine method specificity
-