B
- The bean typeT
- The bean property type@Immutable public interface BeanProperty<B,T> extends Named, AnnotationMetadataDelegate
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.
BeanIntrospection
CLASS_NAME_SUFFIX, EMPTY_METADATA, VALUE_MEMBER
EMPTY
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 |
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.
|
booleanValue, booleanValue, booleanValue, booleanValue, classValue, classValue, classValue, classValue, classValues, classValues, classValues, classValues, doubleValue, doubleValue, doubleValue, enumValue, enumValue, enumValue, enumValue, findAnnotation, findAnnotation, findDeclaredAnnotation, findDeclaredAnnotation, getAnnotation, getAnnotation, getAnnotationNameByStereotype, getAnnotationNameByStereotype, getAnnotationNames, getAnnotationNamesByStereotype, getAnnotationNamesByStereotype, getAnnotationType, getAnnotationTypeByStereotype, getAnnotationTypeByStereotype, getAnnotationTypesByStereotype, getAnnotationValuesByType, getDeclaredAnnotation, getDeclaredAnnotation, getDeclaredAnnotationNameByStereotype, getDeclaredAnnotationNames, getDeclaredAnnotationNamesByStereotype, getDeclaredAnnotationTypeByStereotype, getDeclaredAnnotationTypeByStereotype, getDeclaredAnnotationValuesByType, getDefaultValue, getDefaultValue, getDefaultValue, getDefaultValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValues, getValues, hasAnnotation, hasAnnotation, hasDeclaredAnnotation, hasDeclaredAnnotation, hasDeclaredStereotype, hasDeclaredStereotype, hasDeclaredStereotype, hasStereotype, hasStereotype, hasStereotype, hasStereotype, intValue, intValue, intValue, isAnnotationPresent, isDeclaredAnnotationPresent, isEmpty, isFalse, isFalse, isPresent, isPresent, isTrue, isTrue, longValue, longValue, stringValue, stringValue, stringValue, stringValue, stringValues, stringValues, synthesize, synthesizeAll, synthesizeAnnotationsByType, synthesizeDeclared, synthesizeDeclared, synthesizeDeclaredAnnotationsByType
getAnnotationMetadata
@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 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 converteddefault Argument<T> asArgument()
default boolean isReadOnly()
default boolean isWriteOnly()
default boolean isReadWrite()