Record Class HandlerMethodApplicability<M>
java.lang.Object
java.lang.Record
io.fluxzero.common.handling.HandlerMethodApplicability<M>
- Type Parameters:
M- the message type used by the handling pipeline- Record Components:
cacheKey- a stable key containing every input property that affects the result, ornullwhen safe caching is unsupportedpayloadClassKey- whether the payload's runtime class alone is a complete key for this resultpreparation- whether the method matches and, if so, the prepared invocation plan
public record HandlerMethodApplicability<M>(Object cacheKey, boolean payloadClassKey, HandlerMethodPreparation<M> preparation)
extends Record
Describes whether a handler method applies to a group of equivalent inputs and, when it does, how to invoke it.
Fluxzero uses this result to cache both matches and non-matches without changing handler selection. Equal
cacheKey values must therefore mean that the same HandlerMethodPreparation is valid for both
inputs.
-
Constructor Summary
ConstructorsConstructorDescriptionHandlerMethodApplicability(Object cacheKey, boolean payloadClassKey, HandlerMethodPreparation<M> preparation) Creates an instance of aHandlerMethodApplicabilityrecord class. -
Method Summary
Modifier and TypeMethodDescriptionstatic <M> HandlerMethodApplicability<M> cacheable(Object cacheKey, boolean payloadClassKey, HandlerMethodPreparation<M> preparation) Creates a result that may be reused for inputs with the same cache key.cacheKey()Returns the value of thecacheKeyrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.booleanReturns whether this result may be reused for another input with the same key.booleanReturns the value of thepayloadClassKeyrecord component.Returns the value of thepreparationrecord component.final StringtoString()Returns a string representation of this record class.static <M> HandlerMethodApplicability<M> Returns a result indicating that applicability cannot be prepared safely for this input.withPreparation(HandlerMethodPreparation<M> newPreparation) Copies this result with a different preparation while retaining its cache guarantees.
-
Constructor Details
-
HandlerMethodApplicability
public HandlerMethodApplicability(Object cacheKey, boolean payloadClassKey, HandlerMethodPreparation<M> preparation) Creates an instance of aHandlerMethodApplicabilityrecord class.- Parameters:
cacheKey- the value for thecacheKeyrecord componentpayloadClassKey- the value for thepayloadClassKeyrecord componentpreparation- the value for thepreparationrecord component
-
-
Method Details
-
cacheable
public static <M> HandlerMethodApplicability<M> cacheable(Object cacheKey, boolean payloadClassKey, HandlerMethodPreparation<M> preparation) Creates a result that may be reused for inputs with the same cache key.- Parameters:
cacheKey- a stable key containing every input property that affects the resultpayloadClassKey- whether the payload's runtime class alone is sufficient as the keypreparation- a prepared match or definitive non-match- Returns:
- the cacheable applicability result
-
unsupported
Returns a result indicating that applicability cannot be prepared safely for this input.The caller should use normal per-message handler selection instead.
- Returns:
- an unsupported result
-
isCacheable
public boolean isCacheable()Returns whether this result may be reused for another input with the same key.- Returns:
trueif this result has a complete cache key
-
withPreparation
Copies this result with a different preparation while retaining its cache guarantees.This is intended for handler decorators that do not change when the underlying handler applies, but that do wrap, reject, or otherwise transform its invocation plan. If the new preparation is unsupported, the returned applicability is unsupported as well.
- Parameters:
newPreparation- the replacement preparation- Returns:
- a result with the same key guarantees and the replacement preparation
-
toString
-
hashCode
-
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. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
cacheKey
-
payloadClassKey
public boolean payloadClassKey()Returns the value of thepayloadClassKeyrecord component.- Returns:
- the value of the
payloadClassKeyrecord component
-
preparation
Returns the value of thepreparationrecord component.- Returns:
- the value of the
preparationrecord component
-