Class HandlerAssociations

java.lang.Object
io.fluxzero.sdk.tracking.handling.HandlerAssociations

public class HandlerAssociations extends Object
Shared utility for discovering and evaluating Association definitions on handler types and handler methods.

This class centralizes association behavior that is shared between different handler implementations, such as StatefulHandler and SocketEndpointHandler. It can:

  • inspect field-, method-, and parameter-level @Association declarations
  • resolve association values from an incoming DeserializingMessage
  • match a concrete handler instance against computed association values
  • Constructor Details

    • HandlerAssociations

      public HandlerAssociations(@NonNull @NonNull Class<?> targetClass, List<io.fluxzero.common.handling.ParameterResolver<? super DeserializingMessage>> parameterResolvers, Function<Executable, ? extends Annotation> methodAnnotationProvider)
      Creates an association helper for a specific handler type.
      Parameters:
      targetClass - the handler class whose association metadata should be inspected
      parameterResolvers - the parameter resolvers used to resolve parameter-level @Association sources
      methodAnnotationProvider - provider for the effective handler annotation on an executable, used when resolving parameter values
  • Method Details

    • getAssociationProperties

      public Map<String, HandlerAssociations.AssociationValue> getAssociationProperties()
      Returns the association definitions declared on the handler type itself, keyed by message property name.
    • getMethodAssociationProperties

      public List<HandlerAssociations.MethodAssociationProperty> getMethodAssociationProperties(Executable executable)
      Returns the association definitions contributed by a handler executable, including parameter-level @Association declarations.
    • associations

      public Map<Object,String> associations(DeserializingMessage message, Stream<Executable> matchingMethods)
      Computes the association values contributed by the given message for the supplied matching handler methods.

      The returned map is keyed by association value and contains the target path within the handler instance that should be matched for that value.

    • matchesTarget

      public boolean matchesTarget(Object target, Map<Object,String> associations)
      Returns whether the given handler instance matches any of the computed association values.
    • matchesValue

      protected boolean matchesValue(Object targetValue, Object associationValue)
    • normalizeAssociationValue

      protected Object normalizeAssociationValue(Object value)
    • includedPayload

      protected boolean includedPayload(Object payload, HandlerAssociations.AssociationValue association)
    • computeMethodAssociationProperties

      protected List<HandlerAssociations.MethodAssociationProperty> computeMethodAssociationProperties(Executable executable)
    • alwaysAssociate

      public boolean alwaysAssociate(Executable executable)
      Returns whether the executable's association metadata allows unconditional association.
    • resolveParameterValue

      protected Object resolveParameterValue(Executable executable, Parameter parameter, Annotation methodAnnotation, DeserializingMessage message)
    • applicableParameterResolvers

      protected List<io.fluxzero.common.handling.ParameterResolver<? super DeserializingMessage>> applicableParameterResolvers(Executable executable)
    • mayApply

      protected boolean mayApply(io.fluxzero.common.handling.ParameterResolver<? super DeserializingMessage> resolver, Executable executable)