Class AnnotatedCaster<T>
java.lang.Object
io.fluxcapacitor.javaclient.common.serialization.casting.AnnotatedCaster<T>
- Type Parameters:
T
- the underlying type of the serialized data
Represents a dynamically discovered casting method (annotated with
Upcast
or Downcast
)
that is bound to a specific data revision and type.
This class delegates casting logic to a functional wrapper around the annotated method, and is
typically instantiated by CastInspector
as part of building a CasterChain
.
-
Constructor Summary
ConstructorsConstructorDescriptionAnnotatedCaster
(Method method, CastParameters castParameters, Function<SerializedObject<T>, Stream<SerializedObject<T>>> castFunction) Creates a newAnnotatedCaster
. -
Method Summary
-
Constructor Details
-
AnnotatedCaster
public AnnotatedCaster(Method method, CastParameters castParameters, Function<SerializedObject<T>, Stream<SerializedObject<T>>> castFunction) Creates a newAnnotatedCaster
.- Parameters:
method
- the underlying Java method that performs castingcastParameters
- the parameters from theCast
annotation (e.g., type and revision)castFunction
- a function that applies the casting logic to a givenSerializedObject
-
-
Method Details
-
cast
Applies the casting logic to the given serialized object if its type and revision match this caster’s parameters. If the input does not match, it is returned unmodified.- Type Parameters:
S
- the input and output serialized object type- Parameters:
input
- the serialized object to potentially cast- Returns:
- a stream containing the casted result(s) or the original input if no match was found
-
toString
-