Interface BeanWriteProperty<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>, UnsafeBeanWriteProperty<B,T>
All Known Implementing Classes:

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

A BeanWriteProperty allows you to write to it via set(Object, Object), without using reflection.

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

Denis Stepanov
See Also:
  • Method Details

    • getDeclaringBean

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

      @NonNull default @NonNull Class<B> getDeclaringType()
      The declaring type of the property.
      The type
    • withValue

      B withValue(@NonNull B bean, @Nullable T value)
      This method will attempt to modify the property or if this is an immutable type using a copy constructor to return a new instance with the new value.

      This differs from set(Object, Object) which will throw an exception if the property does not have a setter.

      • If the property is read-only but can be provided via constructor argument a new instance representing a copy of the bean is returned.
      • If the property is mutable then the passed instance is returned and set(Object, Object) invoked to mutate the property
      • If there is no way for the property to be mutated then an UnsupportedOperationException is thrown
      bean - The bean
      value - The new value
      Either the existing instance or the property is mutable or a newly created instance via the copy constructor pattern.
      UnsupportedOperationException - if the property cannot be mutated
    • set

      void set(@NonNull B bean, @Nullable T value)
      Write the bean value.
      bean - The bean
      value - The value to write
      IllegalArgumentException - If either the bean type or value type are not correct
    • convertAndSet

      default void convertAndSet(@NonNull B bean, @Nullable @Nullable Object value)
      Convert the value and set if on the bean using the default conversion service.
      bean - The bean
      value - The value
      ConversionErrorException - If the value couldn't be converted
    • getType

      @NonNull @NonNull Class<T> getType()
      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>
      The argument