Interface BeanReadProperty<B,T>

Type Parameters:
B - The bean type
T - The bean property type
All Superinterfaces:
AnnotatedElement, AnnotationMetadata, AnnotationMetadataDelegate, AnnotationMetadataProvider, AnnotationSource, ArgumentCoercible<T>, Named
All Known Subinterfaces:
BeanProperty<B,T>, UnsafeBeanProperty<B,T>, UnsafeBeanReadProperty<B,T>
All Known Implementing Classes:
AbstractBeanProperty

public interface BeanReadProperty<B,T> extends AnnotatedElement, AnnotationMetadataDelegate, ArgumentCoercible<T>
Represents a read write property of a bean.

A BeanReadProperty allows you to read the value of a property via get(Object), without using reflection.

The annotations of a property can be inspected via the AnnotationMetadataProvider.getAnnotationMetadata() method.

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

    • getDeclaringBean

      @NonNull @NonNull BeanIntrospection<B> getDeclaringBean()
      Returns:
      The declaring bean introspection.
    • getDeclaringType

      default Class<B> getDeclaringType()
      The declaring type of the property.
      Returns:
      The type
    • get

      @Nullable T get(@NonNull B bean)
      Read the bean value.
      Parameters:
      bean - The bean to read from
      Returns:
      The value
      Throws:
      IllegalArgumentException - If the bean instance if not of the correct type
    • get

      @NonNull default <T2> @NonNull Optional<T2> get(@NonNull B bean, @NonNull @NonNull Class<T2> type)
      Read the value and try to convert it to the given type.
      Type Parameters:
      T2 - The generic type
      Parameters:
      bean - The bean
      type - The type
      Returns:
      The value if conversion was possible.
    • get

      default <T2> Optional<T2> get(@NonNull B bean, @NonNull @NonNull Argument<T2> argument)
      Read the value and try to convert it to the given type.
      Type Parameters:
      T2 - The generic type
      Parameters:
      bean - The bean
      argument - The type
      Returns:
      The value if conversion was possible.
    • get

      default <T2> Optional<T2> get(@NonNull B bean, @NonNull @NonNull ArgumentConversionContext<T2> conversionContext)
      Read the value and try to convert it to the given type.
      Type Parameters:
      T2 - The generic type
      Parameters:
      bean - The bean
      conversionContext - The conversion context to use
      Returns:
      The value if conversion was possible.
    • get

      @Nullable default <T2> T2 get(@NonNull B bean, @NonNull @NonNull Class<T2> type, @Nullable T2 defaultValue)
      Read the value and try to convert it to the given type.
      Type Parameters:
      T2 - The generic type
      Parameters:
      bean - The bean
      type - The type
      defaultValue - The default value if conversion is not possible
      Returns:
      The value if conversion was possible.
    • getType

      @NonNull @NonNull Class<T> getType()
      Returns:
      The property type.
    • asArgument

      @NonNull default @NonNull Argument<T> asArgument()
      Represent the type as an argument, including any generic type information.
      Specified by:
      asArgument in interface ArgumentCoercible<B>
      Returns:
      The argument