Package io.micronaut.core.beans
Class AbstractBeanIntrospection<T>
java.lang.Object
io.micronaut.core.beans.AbstractBeanIntrospection<T>
- Type Parameters:
T
- The generic type
- All Implemented Interfaces:
AnnotationMetadata
,AnnotationMetadataDelegate
,AnnotationMetadataProvider
,AnnotationSource
,BeanInfo<T>
,BeanIntrospection<T>
,ArgumentCoercible<T>
@Internal
public abstract class AbstractBeanIntrospection<T>
extends Object
implements BeanIntrospection<T>
Abstract implementation of the
BeanIntrospection
interface. This class is subclasses at compilation time by generated byte code and should not be used directly.- Since:
- 1.1
- Author:
- graemerocher
-
Field Summary
Modifier and TypeFieldDescriptionprotected final AnnotationMetadata
protected final List<BeanMethod<T,
Object>> protected final Map<String,
BeanProperty<T, Object>> 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
AbstractBeanIntrospection
(Class<T> beanType, AnnotationMetadata annotationMetadata, int propertyCount) Base class for bean instrospections.protected
AbstractBeanIntrospection
(Class<T> beanType, AnnotationMetadata annotationMetadata, int propertyCount, int methodCount) Base class for bean instrospections. -
Method Summary
Modifier and TypeMethodDescriptionprotected final void
addMethod
(BeanMethod<T, Object> method) Adds a method to the introspection.protected final void
addProperty
(BeanProperty<T, Object> property) Adds a property at a particular index of the internal array passed to the constructor.boolean
Supplies the metadata.Returns theBeanMethod
instances for this introspection.The bean type.protected AnnotationMetadata
getIndexedProperties
(Class<? extends Annotation> annotationType) Get all the bean properties annotated for the given annotation type.getIndexedProperty
(Class<? extends Annotation> annotationType, String annotationValue) Get all the bean properties annotated for the given type.getProperty
(String name) Obtain a property by name.int
hashCode()
protected final void
indexProperty
(Class<? extends Annotation> annotationType, String propertyName) Used to produce an index for particular annotation type.protected final void
indexProperty
(Class<? extends Annotation> annotationType, String propertyName, String annotationValue) Used to produce an index for particular annotation type.instantiate
(boolean strictNullable, Object... arguments) Instantiates an instance of the bean, throwing an exception is instantiation is not possible.protected abstract T
instantiateInternal
(Object[] arguments) Reflection free bean instantiation implementation for the given arguments.int
propertyIndexOf
(String name) Obtain the property index position.toString()
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
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.BeanInfo
asArgument, getGenericBeanType
Methods inherited from interface io.micronaut.core.beans.BeanIntrospection
getConstructorArguments, getIndexedProperty, getProperty, getPropertyNames, getRequiredProperty, instantiate, instantiate
-
Field Details
-
annotationMetadata
-
beanType
-
beanProperties
-
beanMethods
-
-
Constructor Details
-
AbstractBeanIntrospection
protected AbstractBeanIntrospection(@NonNull Class<T> beanType, @Nullable AnnotationMetadata annotationMetadata, int propertyCount) Base class for bean instrospections.- Parameters:
beanType
- The bean typeannotationMetadata
- The annotation metadatapropertyCount
- The property count
-
AbstractBeanIntrospection
protected AbstractBeanIntrospection(@NonNull Class<T> beanType, @Nullable AnnotationMetadata annotationMetadata, int propertyCount, int methodCount) Base class for bean instrospections.- Parameters:
beanType
- The bean typeannotationMetadata
- The annotation metadatapropertyCount
- The property countmethodCount
- The method count
-
-
Method Details
-
getConstructor
- Specified by:
getConstructor
in interfaceBeanIntrospection<T>
- Returns:
- The bean constructor.
-
getConstructorAnnotationMetadata
- Returns:
- Annotation metadata for the constructor.
- Since:
- 3.0.0
-
getIndexedProperty
@NonNull public Optional<BeanProperty<T,Object>> getIndexedProperty(@NonNull Class<? extends Annotation> annotationType, @NonNull String annotationValue) Description copied from interface:BeanIntrospection
Get all the bean properties annotated for the given type.- Specified by:
getIndexedProperty
in interfaceBeanIntrospection<T>
- Parameters:
annotationType
- The annotation typeannotationValue
- The annotation value- Returns:
- A immutable collection of properties.
- See Also:
-
instantiate
@NonNull public T instantiate(boolean strictNullable, Object... arguments) throws InstantiationException Description copied from interface:BeanIntrospection
Instantiates an instance of the bean, throwing an exception is instantiation is not possible.- Specified by:
instantiate
in interfaceBeanIntrospection<T>
- Parameters:
strictNullable
- If true, require null parameters to be annotated with a nullable annotationarguments
- The arguments required to instantiate bean. Should match the types returned byBeanIntrospection.getConstructorArguments()
- Returns:
- An instance
- Throws:
InstantiationException
- If the bean cannot be instantiated.
-
getProperty
Description copied from interface:BeanIntrospection
Obtain a property by name.- Specified by:
getProperty
in interfaceBeanIntrospection<T>
- Parameters:
name
- The name of the property- Returns:
- A bean property if found
-
propertyIndexOf
Description copied from interface:BeanIntrospection
Obtain the property index position.- Specified by:
propertyIndexOf
in interfaceBeanIntrospection<T>
- Parameters:
name
- The name of the property- Returns:
- A property index or -1 of not found.
-
getIndexedProperties
@NonNull public Collection<BeanProperty<T,Object>> getIndexedProperties(@NonNull Class<? extends Annotation> annotationType) Description copied from interface:BeanIntrospection
Get all the bean properties annotated for the given annotation type. If the annotation isIntrospected.indexed()
by the given annotation, then it will be included in the resulting list.- Specified by:
getIndexedProperties
in interfaceBeanIntrospection<T>
- Parameters:
annotationType
- The annotation type- Returns:
- A immutable collection of properties.
- See Also:
-
getAnnotationMetadata
Description copied from interface:AnnotationMetadataProvider
Supplies the metadata. Defaults toAnnotationMetadata.EMPTY_METADATA
.- Specified by:
getAnnotationMetadata
in interfaceAnnotationMetadataProvider
- Returns:
- The
AnnotationMetadata
-
getBeanProperties
- Specified by:
getBeanProperties
in interfaceBeanIntrospection<T>
- Returns:
- A immutable collection of properties.
-
getBeanType
Description copied from interface:BeanIntrospection
The bean type.- Specified by:
getBeanType
in interfaceBeanInfo<T>
- Specified by:
getBeanType
in interfaceBeanIntrospection<T>
- Returns:
- The bean type
-
instantiateInternal
Reflection free bean instantiation implementation for the given arguments.- Parameters:
arguments
- The arguments- Returns:
- The bean
-
addProperty
Adds a property at a particular index of the internal array passed to the constructor. Used by generated byte code for subclasses and not for public consumption.- Parameters:
property
- The property.
-
addMethod
Adds a method to the introspection. Used by generated byte code for subclasses and not for public consumption.- Parameters:
method
- The property.
-
getBeanMethods
Description copied from interface:BeanIntrospection
Returns theBeanMethod
instances for this introspection.The
BeanMethod
instances are only those methods annotated withio.micronaut.context.annotation.Executable
and hence represent a subset of the actual methods of the class and do not include any methods that are exposed asBeanProperty
instances.- Specified by:
getBeanMethods
in interfaceBeanIntrospection<T>
- Returns:
- A immutable collection of methods.
-
indexProperty
@Internal protected final void indexProperty(@NonNull Class<? extends Annotation> annotationType, @NonNull String propertyName) Used to produce an index for particular annotation type. Method referenced by generated byte code and not for public consumption. Should be called afteraddProperty(BeanProperty)
if required.- Parameters:
annotationType
- The annotation typepropertyName
- The property name
-
indexProperty
@Internal protected final void indexProperty(@NonNull Class<? extends Annotation> annotationType, @NonNull String propertyName, @Nullable String annotationValue) Used to produce an index for particular annotation type. Method referenced by generated byte code and not for public consumption. Should be called afteraddProperty(BeanProperty)
if required.- Parameters:
annotationType
- The annotation typepropertyName
- The property nameannotationValue
- The annotation value
-
equals
-
hashCode
public int hashCode() -
toString
-