Class CastInspector
java.lang.Object
io.fluxcapacitor.javaclient.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 (typicallyUpcast
orDowncast
) in the provided candidates, and wraps them asAnnotatedCaster
instances.static boolean
hasCasterMethods
(Class<?> type) Returnstrue
if the given class contains any method annotated withCast
.
-
Constructor Details
-
CastInspector
public CastInspector()
-
-
Method Details
-
hasCasterMethods
Returnstrue
if the given class contains any method annotated withCast
.- Parameters:
type
- the class to inspect- Returns:
- true if at least one casting method is present, false otherwise
-
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 (typicallyUpcast
orDowncast
) in the provided candidates, and wraps them asAnnotatedCaster
instances.- 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
-