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_MEMBERFields inherited from interface io.micronaut.core.annotation.AnnotationSource
EMPTY -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractBeanProperty(@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.booleanfinal PRead the bean value.Supplies the metadata.final @NonNull BeanIntrospection<B>getName()getType()final PUnsafe version ofBeanReadProperty.get(Object).inthashCode()protected abstract PreadInternal(B bean) Reads the bean property.final voidWrite the bean value.final voidUnsafe 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 BwithValueInternal(B bean, P value) Mutates a property value.final BwithValueUnsafe(B bean, P value) Unsafe version ofBeanWriteProperty.withValue(Object, Object).protected abstract voidwriteInternal(B bean, P value) Writes a property value.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface io.micronaut.core.annotation.AnnotatedElement
isDeclaredNonNull, isDeclaredNullable, isNonNull, isNullableMethods inherited from interface io.micronaut.core.annotation.AnnotationMetadata
enumValuesSet, enumValuesSet, getValues, hasDeclaredStereotype, hasEvaluatedExpressions, hasStereotypeNonRepeating, isAnnotationPresent, isDeclaredAnnotationPresentMethods 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, synthesizeDeclaredAnnotationsByTypeMethods inherited from interface io.micronaut.core.beans.BeanProperty
convertAndSet, get, get, get, get, getDeclaringType, hasSetterOrConstructorArgument, isReadOnly, isReadWrite, isWriteOnlyMethods 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:
getTypein interfaceBeanProperty<B,P> - Specified by:
getTypein interfaceBeanReadProperty<B,P> - Specified by:
getTypein interfaceBeanWriteProperty<B,P> - Returns:
- The property type.
-
asArgument
Description copied from interface:BeanWritePropertyRepresent the type as an argument, including any generic type information.- Specified by:
asArgumentin interfaceArgumentCoercible<B>- Specified by:
asArgumentin interfaceBeanProperty<B,P> - Specified by:
asArgumentin interfaceBeanReadProperty<B,P> - Specified by:
asArgumentin interfaceBeanWriteProperty<B,P> - Returns:
- The argument
-
getDeclaringBean
- Specified by:
getDeclaringBeanin interfaceBeanProperty<B,P> - Specified by:
getDeclaringBeanin interfaceBeanReadProperty<B,P> - Specified by:
getDeclaringBeanin interfaceBeanWriteProperty<B,P> - Returns:
- The declaring bean introspection.
-
getAnnotationMetadata
Description copied from interface:AnnotationMetadataProviderSupplies the metadata. Defaults toAnnotationMetadata.EMPTY_METADATA.- Specified by:
getAnnotationMetadatain interfaceAnnotationMetadataProvider- Returns:
- The
AnnotationMetadata
-
get
Description copied from interface:BeanReadPropertyRead the bean value.- Specified by:
getin interfaceBeanProperty<B,P> - Specified by:
getin interfaceBeanReadProperty<B,P> - Parameters:
bean- The bean to read from- Returns:
- The value
-
getUnsafe
Description copied from interface:UnsafeBeanPropertyUnsafe version ofBeanReadProperty.get(Object).- Specified by:
getUnsafein interfaceUnsafeBeanProperty<B,P> - Specified by:
getUnsafein interfaceUnsafeBeanReadProperty<B,P> - Parameters:
bean- The bean to read from- Returns:
- The value
-
withValue
Description copied from interface:BeanWritePropertyThis 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
UnsupportedOperationExceptionis thrown
- Specified by:
withValuein interfaceBeanProperty<B,P> - Specified by:
withValuein 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:UnsafeBeanPropertyUnsafe version ofBeanWriteProperty.withValue(Object, Object).- Specified by:
withValueUnsafein interfaceUnsafeBeanProperty<B,P> - Specified by:
withValueUnsafein 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:BeanWritePropertyWrite the bean value.- Specified by:
setin interfaceBeanProperty<B,P> - Specified by:
setin interfaceBeanWriteProperty<B,P> - Parameters:
bean- The beanvalue- The value to write
-
setUnsafe
Description copied from interface:UnsafeBeanPropertyUnsafe version ofBeanWriteProperty.set(Object, Object).- Specified by:
setUnsafein interfaceUnsafeBeanProperty<B,P> - Specified by:
setUnsafein 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
-