Class AnnotatedCaster<T>

java.lang.Object
io.fluxzero.sdk.common.serialization.casting.AnnotatedCaster<T>
Type Parameters:
T - the underlying type of the serialized data

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

    • AnnotatedCaster

      public AnnotatedCaster(Method method, CastParameters castParameters, Function<io.fluxzero.common.api.SerializedObject<T>, Stream<io.fluxzero.common.api.SerializedObject<T>>> castFunction)
      Creates a new AnnotatedCaster.
      Parameters:
      method - the underlying Java method that performs casting
      castParameters - the parameters from the Cast annotation (e.g., type and revision)
      castFunction - a function that applies the casting logic to a given SerializedObject
  • Method Details

    • cast

      public <S extends io.fluxzero.common.api.SerializedObject<T>> Stream<S> cast(S input)
      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
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object