Package io.micronaut.core.beans
Class AbstractBeanProperty<B,P>
java.lang.Object
io.micronaut.core.beans.AbstractBeanProperty<B,P>
- Type Parameters:
B
- The bean typeP
- The property type
- All Implemented Interfaces:
AnnotatedElement
,AnnotationMetadata
,AnnotationMetadataDelegate
,AnnotationMetadataProvider
,AnnotationSource
,BeanProperty<B,
,P> BeanReadProperty<B,
,P> BeanWriteProperty<B,
,P> UnsafeBeanProperty<B,
,P> UnsafeBeanReadProperty<B,
,P> UnsafeBeanWriteProperty<B,
,P> Named
,ArgumentCoercible<P>
@Internal
public abstract class AbstractBeanProperty<B,P>
extends Object
implements UnsafeBeanProperty<B,P>
Abstract implementation of
BeanProperty
. Generated byte code should be used to create a subclass
and implement the BeanProperty.get(Object)
and BeanProperty.set(Object, Object)
methods. This class is subclasses at compilation time by generated byte code and should not be used directly.- Since:
- 1.1
- Author:
- graemerocher
-
Field Summary
Fields inherited from interface io.micronaut.core.annotation.AnnotationMetadata
CLASS_NAME_SUFFIX, EMPTY_METADATA, VALUE_MEMBER
Fields inherited from interface io.micronaut.core.annotation.AnnotationSource
EMPTY
-
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractBeanProperty
(@NonNull BeanIntrospection<B> introspection, @NonNull Class<P> type, @NonNull String name, @Nullable AnnotationMetadata annotationMetadata, @Nullable Argument[] typeArguments) Default constructor. -
Method Summary
Modifier and TypeMethodDescriptionRepresent the type as an argument, including any generic type information.boolean
final P
Read the bean value.Supplies the metadata.final @NonNull BeanIntrospection<B>
getName()
getType()
final P
Unsafe version ofBeanReadProperty.get(Object)
.int
hashCode()
protected abstract P
readInternal
(B bean) Reads the bean property.final void
Write the bean value.final void
Unsafe version ofBeanWriteProperty.set(Object, Object)
.toString()
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.protected B
withValueInternal
(B bean, P value) Mutates a property value.final B
withValueUnsafe
(B bean, P value) Unsafe version ofBeanWriteProperty.withValue(Object, Object)
.protected abstract void
writeInternal
(B bean, P value) Writes a property value.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface io.micronaut.core.annotation.AnnotatedElement
isDeclaredNonNull, isDeclaredNullable, isNonNull, isNullable
Methods inherited from interface io.micronaut.core.annotation.AnnotationMetadata
enumValuesSet, enumValuesSet, getValues, hasDeclaredStereotype, hasEvaluatedExpressions, hasStereotypeNonRepeating, isAnnotationPresent, isDeclaredAnnotationPresent
Methods inherited from interface io.micronaut.core.annotation.AnnotationMetadataDelegate
booleanValue, booleanValue, booleanValue, booleanValue, classValue, classValue, classValue, classValue, classValues, classValues, classValues, classValues, copyAnnotationMetadata, 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, getAnnotationValuesByName, getAnnotationValuesByStereotype, getAnnotationValuesByType, getDeclaredAnnotation, getDeclaredAnnotation, getDeclaredAnnotationNameByStereotype, getDeclaredAnnotationNames, getDeclaredAnnotationNamesByStereotype, getDeclaredAnnotationTypeByStereotype, getDeclaredAnnotationTypeByStereotype, getDeclaredAnnotationValuesByName, getDeclaredAnnotationValuesByType, getDeclaredMetadata, getDeclaredStereotypeAnnotationNames, getDefaultValue, getDefaultValue, getDefaultValue, getDefaultValue, getDefaultValues, getStereotypeAnnotationNames, getTargetAnnotationMetadata, 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, synthesizeDeclaredAnnotationsByType
Methods inherited from interface io.micronaut.core.beans.BeanProperty
convertAndSet, get, get, get, get, getDeclaringType, hasSetterOrConstructorArgument, isReadOnly, isReadWrite, isWriteOnly
Methods inherited from interface io.micronaut.core.beans.BeanWriteProperty
getDeclaringType
-
Constructor Details
-
AbstractBeanProperty
@Internal protected AbstractBeanProperty(@NonNull @NonNull BeanIntrospection<B> introspection, @NonNull @NonNull Class<P> type, @NonNull @NonNull String name, @Nullable @Nullable AnnotationMetadata annotationMetadata, @Nullable @Nullable Argument[] typeArguments) Default constructor.- Parameters:
introspection
- The parent introspectiontype
- The property typename
- The property nameannotationMetadata
- The annotation metadatatypeArguments
- optional type arguments
-
-
Method Details
-
getName
-
getType
- Specified by:
getType
in interfaceBeanProperty<B,
P> - Specified by:
getType
in interfaceBeanReadProperty<B,
P> - Specified by:
getType
in interfaceBeanWriteProperty<B,
P> - Returns:
- The property type.
-
asArgument
Description copied from interface:BeanWriteProperty
Represent the type as an argument, including any generic type information.- Specified by:
asArgument
in interfaceArgumentCoercible<B>
- Specified by:
asArgument
in interfaceBeanProperty<B,
P> - Specified by:
asArgument
in interfaceBeanReadProperty<B,
P> - Specified by:
asArgument
in interfaceBeanWriteProperty<B,
P> - Returns:
- The argument
-
getDeclaringBean
- Specified by:
getDeclaringBean
in interfaceBeanProperty<B,
P> - Specified by:
getDeclaringBean
in interfaceBeanReadProperty<B,
P> - Specified by:
getDeclaringBean
in interfaceBeanWriteProperty<B,
P> - Returns:
- The declaring bean introspection.
-
getAnnotationMetadata
Description copied from interface:AnnotationMetadataProvider
Supplies the metadata. Defaults toAnnotationMetadata.EMPTY_METADATA
.- Specified by:
getAnnotationMetadata
in interfaceAnnotationMetadataProvider
- Returns:
- The
AnnotationMetadata
-
get
Description copied from interface:BeanReadProperty
Read the bean value.- Specified by:
get
in interfaceBeanProperty<B,
P> - Specified by:
get
in interfaceBeanReadProperty<B,
P> - Parameters:
bean
- The bean to read from- Returns:
- The value
-
getUnsafe
Description copied from interface:UnsafeBeanProperty
Unsafe version ofBeanReadProperty.get(Object)
.- Specified by:
getUnsafe
in interfaceUnsafeBeanProperty<B,
P> - Specified by:
getUnsafe
in interfaceUnsafeBeanReadProperty<B,
P> - Parameters:
bean
- The bean to read from- Returns:
- The value
-
withValue
Description copied from interface:BeanWriteProperty
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
BeanWriteProperty.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
BeanWriteProperty.set(Object, Object)
invoked to mutate the property - If there is no way for the property to be mutated then an
UnsupportedOperationException
is thrown
- Specified by:
withValue
in interfaceBeanProperty<B,
P> - Specified by:
withValue
in interfaceBeanWriteProperty<B,
P> - Parameters:
bean
- The beanvalue
- The new value- Returns:
- Either the existing instance or the property is mutable or a newly created instance via the copy constructor pattern.
-
withValueUnsafe
Description copied from interface:UnsafeBeanProperty
Unsafe version ofBeanWriteProperty.withValue(Object, Object)
.- Specified by:
withValueUnsafe
in interfaceUnsafeBeanProperty<B,
P> - Specified by:
withValueUnsafe
in interfaceUnsafeBeanWriteProperty<B,
P> - Parameters:
bean
- The beanvalue
- The new value- Returns:
- Either the existing instance or the property is mutable or a newly created instance via the copy constructor pattern.
-
set
Description copied from interface:BeanWriteProperty
Write the bean value.- Specified by:
set
in interfaceBeanProperty<B,
P> - Specified by:
set
in interfaceBeanWriteProperty<B,
P> - Parameters:
bean
- The beanvalue
- The value to write
-
setUnsafe
Description copied from interface:UnsafeBeanProperty
Unsafe version ofBeanWriteProperty.set(Object, Object)
.- Specified by:
setUnsafe
in interfaceUnsafeBeanProperty<B,
P> - Specified by:
setUnsafe
in interfaceUnsafeBeanWriteProperty<B,
P> - Parameters:
bean
- The beanvalue
- The value to write
-
withValueInternal
Mutates a property value.- Parameters:
bean
- The beanvalue
- The value- Returns:
- Either a copy of the bean with the copy constructor invoked or the mutated instance if it mutable
- See Also:
-
writeInternal
Writes a property value.- Parameters:
bean
- The beanvalue
- The value
-
readInternal
Reads the bean property.- Parameters:
bean
- The bean- Returns:
- THe value
-
equals
-
hashCode
public int hashCode() -
toString
-