Class EntityParameterResolver
java.lang.Object
io.fluxzero.sdk.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 Fluxzero Runtime usingFluxzero#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 TypeMethodDescriptionbooleanIndicates 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 anEntityinstance matching the given method parameter.protected booleanisAssignable(Parameter parameter, Entity<?> entity) Returnstrueif the entity or any of its parents match the expected parameter type.protected booleanReturnstrueif the entity or any of its parents match the expected parameter type.booleanmatches(Parameter parameter, Annotation methodAnnotation, Object input) Determines whether the parameter can be resolved from the given input.protected Supplier<?> Returns aSupplierthat returns the entity if the entity or any of its parents match the expected parameter type.resolve(Parameter parameter, Annotation methodAnnotation) Provides aSupplierthat returns the matching entity or its value for the given parameter.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ParameterResolver
mayApply, test
-
Constructor Details
-
EntityParameterResolver
public EntityParameterResolver()
-
-
Method Details
-
resolve
Provides aSupplierthat returns the matching entity or its value for the given parameter. Will recursively traverse parent entities if needed.- Specified by:
resolvein 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:
matchesin interfaceParameterResolver<Object>- Parameters:
parameter- the method parametermethodAnnotation- the annotation on the handler method (unused here)input- the handler input (e.g.,DeserializingMessageorHasEntity)- Returns:
- true if the parameter can be resolved from the input, false otherwise
-
getMatchingEntity
Attempts to retrieve anEntityinstance matching the given method parameter.The search is performed on:
HasEntityinput types (directly returning the contained entity)HasMessageinput types (by extracting aggregate metadata and loading the entity)
- Parameters:
input- the message or entity contextparameter- the method parameter being resolved- Returns:
- the matching
Entityornullif not resolvable
-
matches
-
resolve
-
isAssignable
-
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:
determinesSpecificityin interfaceParameterResolver<Object>- Returns:
- true, signaling that this resolver helps determine method specificity
-