Interface BeanPropertyMember<B,T>

Type Parameters:
B - The bean type
T - The member type
All Superinterfaces:
AnnotationMetadataProvider, AnnotationSource, ArgumentCoercible<T>, Named
All Known Subinterfaces:
ReflectiveIntrospection.ReflectivePropertyMember<B>

public interface BeanPropertyMember<B,T> extends AnnotationMetadataProvider, ArgumentCoercible<T>, Named
A single member (a field, a getter or a setter) that contributed to a BeanProperty.

A BeanProperty merges the field, the read method and the write method of a property, and what the super types declare on them, into a single element with a single merged AnnotationMetadata. Some specifications, most notably Jakarta Bean Validation, treat those members as distinct elements: a constraint declared on the field is validated against the value the field holds, while a constraint declared on the getter is validated against the value the getter returns, and the two can differ; a constraint an interface declares on its getter belongs to the implicit group of that interface. A member is one declaration: the field, or the read or write method of one type of the hierarchy, carrying the annotations that declaration carries and not the ones of the methods it overrides.

The members of a property are only available if the introspection was generated with Introspected.members() set to true, otherwise BeanProperty.getMembers() is empty.

Since:
5.2.0
Author:
Denis Stepanov
See Also:
  • Method Details

    • getName

      String getName()
      The name of the member. For a field this is the field name, for a method this is the method name.
      Specified by:
      getName in interface Named
      Returns:
      The member name
    • getElementType

      ElementType getElementType()
      The kind of the member, either ElementType.FIELD or ElementType.METHOD.
      Returns:
      The element type
    • getDeclaringType

      Class<?> getDeclaringType()
      The type that declares this member. Unlike BeanProperty.getDeclaringType() this is the type the member is actually declared on, which can be a supertype of the introspected bean type.
      Returns:
      The declaring type
    • asArgument

      Argument<T> asArgument()
      The type of the member as an argument, including any generic type information and type annotations. For a field this is the field type, for a getter the return type and for a setter the type of the single parameter.
      Specified by:
      asArgument in interface ArgumentCoercible<B>
      Returns:
      The argument
    • getType

      default Class<T> getType()
      Returns:
      The type of the member
    • isReadable

      boolean isReadable()
      Whether the value of this member can be read with read(Object). Fields and getters are readable, setters are not.
      Returns:
      True if the member can be read
    • read

      @Nullable T read(B bean)
      Read the value held by this member. For a field this reads the field directly, bypassing any getter.
      Parameters:
      bean - The bean to read from
      Returns:
      The value
      Throws:
      UnsupportedOperationException - If the member is not readable
      IllegalArgumentException - If the bean instance is not of the correct type