java.lang.Object
io.fluxcapacitor.javaclient.common.serialization.casting.CastInspector

public class CastInspector extends Object
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 Details

    • CastInspector

      public CastInspector()
  • Method Details

    • hasCasterMethods

      public static boolean hasCasterMethods(Class<?> type)
      Returns true if the given class contains any method annotated with Cast.
      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 (typically Upcast or Downcast) in the provided candidates, and wraps them as AnnotatedCaster instances.
      Type Parameters:
      T - the type of the serialized data being cast
      Parameters:
      castAnnotation - the annotation to look for
      candidateTargets - a collection of objects or classes that may define caster methods
      dataType - the expected input/output data type for casting
      Returns:
      a list of discovered annotated casters