B - The bean typeT - The bean property type@Immutable public interface BeanProperty<B,T> extends AnnotatedElement, AnnotationMetadataDelegate, ArgumentCoercible<T>
A BeanProperty allows you to read the value of a property via get(Object) or write to it via set(Object, Object), without using reflection.
The annotations of a property can be inspected via the AnnotationMetadataProvider.getAnnotationMetadata() method.
BeanIntrospectionCLASS_NAME_SUFFIX, EMPTY_METADATA, VALUE_MEMBEREMPTY| Modifier and Type | Method and Description |
|---|---|
default Argument<T> |
asArgument()
Represent the type as an argument, including any generic type information.
|
default void |
convertAndSet(B bean,
Object value)
Convert the value and set if on the bean using the default conversion service.
|
T |
get(B bean)
Read the bean value.
|
default <T2> Optional<T2> |
get(B bean,
Argument<T2> argument)
Read the value and try to convert it to the given type.
|
default <T2> Optional<T2> |
get(B bean,
ArgumentConversionContext<T2> conversionContext)
Read the value and try to convert it to the given type.
|
default <T2> Optional<T2> |
get(B bean,
Class<T2> type)
Read the value and try to convert it to the given type.
|
default <T2> T2 |
get(B bean,
Class<T2> type,
T2 defaultValue)
Read the value and try to convert it to the given type.
|
BeanIntrospection<B> |
getDeclaringBean() |
default Class<B> |
getDeclaringType()
The declaring type of the property.
|
Class<T> |
getType() |
default boolean |
hasSetterOrConstructorArgument()
This method returns true if the property can be mutated either via copy constructor or bean setter.
|
default boolean |
isReadOnly() |
default boolean |
isReadWrite()
Whether the property can be written to and read from.
|
default boolean |
isWriteOnly() |
default void |
set(B bean,
T value)
Write the bean value.
|
default B |
withValue(B bean,
T value)
This method will attempt to modify the property or if this is a immutable type using a copy constructor to return a new instance with the new value.
|
isDeclaredNonNull, isDeclaredNullable, isNonNull, isNullablebooleanValue, booleanValue, booleanValue, booleanValue, classValue, classValue, classValue, classValue, classValues, classValues, classValues, classValues, doubleValue, doubleValue, doubleValue, enumValue, enumValue, enumValue, enumValue, enumValues, enumValues, enumValues, enumValues, findAnnotation, findAnnotation, findDeclaredAnnotation, findDeclaredAnnotation, findRepeatableAnnotation, findRepeatableAnnotation, getAnnotation, getAnnotation, getAnnotationNameByStereotype, getAnnotationNameByStereotype, getAnnotationNames, getAnnotationNamesByStereotype, getAnnotationNamesByStereotype, getAnnotationType, getAnnotationType, getAnnotationTypeByStereotype, getAnnotationTypeByStereotype, getAnnotationTypesByStereotype, getAnnotationTypesByStereotype, getAnnotationTypesByStereotype, getAnnotationValuesByType, getDeclaredAnnotation, getDeclaredAnnotation, getDeclaredAnnotationNameByStereotype, getDeclaredAnnotationNames, getDeclaredAnnotationNamesByStereotype, getDeclaredAnnotationTypeByStereotype, getDeclaredAnnotationTypeByStereotype, getDeclaredAnnotationValuesByType, getDeclaredMetadata, getDefaultValue, getDefaultValue, getDefaultValue, getDefaultValue, getDefaultValues, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValues, getValues, hasAnnotation, hasAnnotation, hasDeclaredAnnotation, hasDeclaredAnnotation, hasDeclaredStereotype, hasDeclaredStereotype, hasDeclaredStereotype, hasPropertyExpressions, hasSimpleAnnotation, hasSimpleDeclaredAnnotation, hasStereotype, hasStereotype, hasStereotype, hasStereotype, intValue, intValue, intValue, isAnnotationPresent, isDeclaredAnnotationPresent, isEmpty, isFalse, isFalse, isPresent, isPresent, isRepeatableAnnotation, isRepeatableAnnotation, isTrue, isTrue, longValue, longValue, stringValue, stringValue, stringValue, stringValue, stringValues, stringValues, stringValues, stringValues, synthesize, synthesize, synthesizeAll, synthesizeAnnotationsByType, synthesizeDeclared, synthesizeDeclared, synthesizeDeclared, synthesizeDeclaredAnnotationsByTypegetAnnotationMetadatagetAnnotationValuesByName, getDeclaredAnnotationValuesByName, getValues, hasDeclaredStereotype, isAnnotationPresent, isDeclaredAnnotationPresent@NonNull BeanIntrospection<B> getDeclaringBean()
@Nullable T get(@NonNull B bean)
bean - The bean to read fromIllegalArgumentException - If the bean instance if not of the correct type@NonNull default <T2> Optional<T2> get(@NonNull B bean, @NonNull Class<T2> type)
T2 - The generic typebean - The beantype - The typedefault <T2> Optional<T2> get(@NonNull B bean, @NonNull Argument<T2> argument)
T2 - The generic typebean - The beanargument - The typedefault <T2> Optional<T2> get(@NonNull B bean, @NonNull ArgumentConversionContext<T2> conversionContext)
T2 - The generic typebean - The beanconversionContext - The conversion context to use@Nullable default <T2> T2 get(@NonNull B bean, @NonNull Class<T2> type, @Nullable T2 defaultValue)
T2 - The generic typebean - The beantype - The typedefaultValue - The default value if conversion is not possibledefault boolean hasSetterOrConstructorArgument()
withValue(Object, Object)default B withValue(@NonNull B bean, @Nullable T value)
This differs from set(Object, Object) which will throw an exception if the property does not have a setter.
set(Object, Object) invoked to mutate the propertyUnsupportedOperationException is thrownbean - The beanvalue - The new valueUnsupportedOperationException - if the property cannot be mutateddefault void set(@NonNull B bean, @Nullable T value)
bean - The beanvalue - The value to writeIllegalArgumentException - If either the bean type or value type are not correctdefault void convertAndSet(@NonNull B bean, @Nullable Object value)
bean - The beanvalue - The valueConversionErrorException - If the value couldn't be converted@NonNull default Argument<T> asArgument()
asArgument in interface ArgumentCoercible<T>default boolean isReadOnly()
default boolean isWriteOnly()
default boolean isReadWrite()