Class ReflectionUtils.TypeMetadata

java.lang.Object
io.fluxzero.common.reflection.ReflectionUtils.TypeMetadata
Enclosing class:
ReflectionUtils

public static final class ReflectionUtils.TypeMetadata extends Object
Lazily computed reflection metadata for a single Java type.

This is the central cache for type-level reflection in Fluxzero. It keeps the structural model of a type together in one place: methods, fields, property descriptors, type annotations, annotated members, cached property-path accessors, and compiled MemberInvoker instances.

  • Method Details

    • type

      public Class<?> type()
      Returns the class whose structural metadata this instance owns.
    • methods

      public List<Method> methods()
      Returns the cached, immutable list of discovered methods across the type hierarchy.
    • defaultConstructor

      public Optional<Constructor<?>> defaultConstructor()
      Returns the type's no-argument constructor, if one exists.
    • method

      public Optional<Method> method(String name)
      Returns the first discovered method with this name, without selecting by parameter types.
    • methods

      public List<Method> methods(String name)
      Returns all discovered overloads with this name, or an empty list if none exists.
    • fields

      public List<Field> fields()
      Returns the cached, immutable list of discovered fields across the type hierarchy.
    • field

      public Optional<Field> field(String name)
      Returns the first discovered field with this name, including inherited fields.
    • declaresField

      public boolean declaresField(String fieldName)
      Returns whether this type itself declares the named field; inherited fields do not count.
    • typeAnnotations

      public Collection<? extends Annotation> typeAnnotations()
      Returns type and interface annotations, deduplicated by annotation type.
    • annotations

      public List<Annotation> annotations(AnnotatedElement element)
      Returns cached annotations for the supplied element.
    • typeAnnotation

      public <A extends Annotation> A typeAnnotation(Class<? extends Annotation> annotationType)
      Returns a matching direct or composed type annotation, or null. For a composed annotation, returns the outer annotation instance.
    • annotatedFields

      public List<Field> annotatedFields(Class<? extends Annotation> annotation)
      Returns fields matching the requested annotation directly or through a meta-annotation.
    • annotatedMethods

      public List<Method> annotatedMethods(Class<? extends Annotation> annotation)
      Returns methods matching the requested annotation, including composed annotations and overridden declarations.
    • annotatedExecutables

      public List<Executable> annotatedExecutables(Class<? extends Annotation> annotation)
      Returns annotated methods, including inherited methods, followed by annotated constructors declared by this type.
    • annotatedProperties

      public List<? extends AccessibleObject> annotatedProperties(Class<? extends Annotation> annotation)
      Returns matching fields and readable methods, including interface properties, deduplicated by logical property name.
    • annotatedProperty

      public Optional<? extends AccessibleObject> annotatedProperty(Class<? extends Annotation> annotation)
      Returns the first matching annotated property, or an empty optional if none exists.
    • annotatedPropertyInvoker

      public Optional<MemberInvoker> annotatedPropertyInvoker(Class<? extends Annotation> annotation)
      Returns a cached invoker for the first matching annotated property, with reflective access enabled.
    • getter

      public Function<Object,Object> getter(String propertyPath)
      Returns a cached reader for a nested property path, accepting dot or slash separators. Missing properties raise ReflectionUtils.PropertyNotFoundException when resolved or read.
    • setter

      public BiConsumer<Object,Object> setter(String propertyPath)
      Returns a cached writer for a nested property path, accepting dot or slash separators. Missing properties raise ReflectionUtils.PropertyNotFoundException when resolved or written.
    • propertyPath

      public ReflectionUtils.TypeMetadata.PropertyPathMetadata propertyPath(String propertyPath)
      Returns cached structural metadata for the normalized nested property path, including missing and dynamically resolved paths.
    • invoker

      public MemberInvoker invoker(Member member, boolean forceAccess)
      Returns the class-owned cached invoker for the member and access policy.
    • specializedMetadata

      public <M> M specializedMetadata(Class<M> metadataType, Function<Class<?>, ? extends M> factory)
      Returns type-specific structural metadata owned by this central type cache.

      SDK features can use this extension point for immutable metadata that is derived only from type(). Runtime or instance state must not be captured by the factory or the returned value. Concurrent or reentrant first access may compute more than one value; all callers receive the first value published successfully.

      Type Parameters:
      M - metadata type
      Parameters:
      metadataType - unique metadata kind and expected result type
      factory - computes non-null metadata from this Java type on first access
      Returns:
      the cached metadata instance
    • fieldAnnotation

      public <A extends Annotation> Optional<A> fieldAnnotation(Field field, Class<? extends Annotation> annotation)
      Returns the field's direct or composed annotation, if present; a composed match returns the outer annotation instance.
    • methodAnnotation

      public <A extends Annotation> Optional<A> methodAnnotation(Executable executable, Class<? extends Annotation> annotation)
      Returns the first direct or composed annotation found along the executable's override hierarchy.
    • methodAnnotations

      public <A extends Annotation> List<A> methodAnnotations(Executable executable, Class<? extends Annotation> annotation)
      Returns matching annotations from the first declaration in the override hierarchy that supplies any.
    • annotationAs

      public <T> Optional<T> annotationAs(AnnotatedElement member, Class<? extends Annotation> annotationType, Class<? extends T> returnType)
      Returns a cached projection of the matching annotation into the requested representation, or an empty optional if absent.