Class CastInspector
java.lang.Object
io.fluxzero.sdk.common.serialization.casting.CastInspector
Internal utility for inspecting and instantiating caster methods based on annotations such as
Upcast or Downcast.
This class is used by DefaultCasterChain to discover methods annotated for casting purposes and wrap
them into AnnotatedCaster instances.
Supports a variety of method signatures for flexibility, including those returning Data<T>, Optional<Data<T>>,
plain T, and Stream<Data<T>>. The inputs may include Data<T>, T, or SerializedMessage.
Not intended for public use.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> List<AnnotatedCaster<T>> getCasters(Class<? extends Annotation> castAnnotation, Collection<?> candidateTargets, Class<T> dataType) Discovers all caster methods annotated with the given annotation (typicallyUpcastorDowncast) in the provided candidates, and wraps them asAnnotatedCasterinstances.static booleanhasCasterMethods(Class<?> type) Returnstrueif the given class contains any method annotated withCast.
-
Constructor Details
-
CastInspector
public CastInspector()
-
-
Method Details
-
hasCasterMethods
-
getCasters
public static <T> List<AnnotatedCaster<T>> getCasters(Class<? extends Annotation> castAnnotation, Collection<?> candidateTargets, Class<T> dataType) Discovers all caster methods annotated with the given annotation (typicallyUpcastorDowncast) in the provided candidates, and wraps them asAnnotatedCasterinstances.- Type Parameters:
T- the type of the serialized data being cast- Parameters:
castAnnotation- the annotation to look forcandidateTargets- a collection of objects or classes that may define caster methodsdataType- the expected input/output data type for casting- Returns:
- a list of discovered annotated casters
-