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
,BeanIntrospection<T>
@Internal public abstract class AbstractBeanIntrospection<T> extends java.lang.Object implements BeanIntrospection<T>
Abstract implementation of theBeanIntrospection
interface. This class is subclasses at compilation time by generated byte code and should not be used directly.- Since:
- 1.1
-
-
Field Summary
Fields Modifier and Type Field Description protected AnnotationMetadata
annotationMetadata
protected java.util.List<BeanMethod<T,java.lang.Object>>
beanMethods
protected java.util.Map<java.lang.String,BeanProperty<T,java.lang.Object>>
beanProperties
protected java.lang.Class<T>
beanType
-
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
Constructors Modifier Constructor Description protected
AbstractBeanIntrospection(java.lang.Class<T> beanType, AnnotationMetadata annotationMetadata, int propertyCount)
Base class for bean instrospections.protected
AbstractBeanIntrospection(java.lang.Class<T> beanType, AnnotationMetadata annotationMetadata, int propertyCount, int methodCount)
Base class for bean instrospections.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
addMethod(BeanMethod<T,java.lang.Object> method)
Adds a method to the introspection.protected void
addProperty(BeanProperty<T,java.lang.Object> property)
Adds a property at a particular index of the internal array passed to the constructor.boolean
equals(java.lang.Object o)
AnnotationMetadata
getAnnotationMetadata()
Supplies the metadata.java.util.Collection<BeanMethod<T,java.lang.Object>>
getBeanMethods()
Returns theBeanMethod
instances for this introspection.java.util.Collection<BeanProperty<T,java.lang.Object>>
getBeanProperties()
java.lang.Class<T>
getBeanType()
The bean type.BeanConstructor<T>
getConstructor()
protected AnnotationMetadata
getConstructorAnnotationMetadata()
java.util.Collection<BeanProperty<T,java.lang.Object>>
getIndexedProperties(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
Get all the bean properties annotated for the given annotation type.java.util.Optional<BeanProperty<T,java.lang.Object>>
getIndexedProperty(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType, java.lang.String annotationValue)
Get all the bean properties annotated for the given type.java.util.Optional<BeanProperty<T,java.lang.Object>>
getProperty(java.lang.String name)
Obtain a property by name.int
hashCode()
protected void
indexProperty(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType, java.lang.String propertyName)
Used to produce an index for particular annotation type.protected void
indexProperty(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType, java.lang.String propertyName, java.lang.String annotationValue)
Used to produce an index for particular annotation type.T
instantiate(boolean strictNullable, java.lang.Object... arguments)
Instantiates an instance of the bean, throwing an exception is instantiation is not possible.protected abstract T
instantiateInternal(java.lang.Object[] arguments)
Reflection free bean instantiation implementation for the given arguments.int
propertyIndexOf(java.lang.String name)
Obtain the property index position.java.lang.String
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
getAnnotationValuesByName, getAnnotationValuesByStereotype, getDeclaredAnnotationValuesByName, getValues, hasDeclaredStereotype, isAnnotationPresent, isDeclaredAnnotationPresent
-
Methods inherited from interface io.micronaut.core.annotation.AnnotationMetadataDelegate
booleanValue, 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, getDeclaredStereotypeAnnotationNames, getDefaultValue, getDefaultValue, getDefaultValue, getDefaultValue, getDefaultValues, getStereotypeAnnotationNames, 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.BeanIntrospection
getConstructorArguments, getIndexedProperty, getProperty, getPropertyNames, getRequiredProperty, instantiate, instantiate
-
-
-
-
Field Detail
-
annotationMetadata
protected final AnnotationMetadata annotationMetadata
-
beanType
protected final java.lang.Class<T> beanType
-
beanProperties
protected final java.util.Map<java.lang.String,BeanProperty<T,java.lang.Object>> beanProperties
-
beanMethods
protected final java.util.List<BeanMethod<T,java.lang.Object>> beanMethods
-
-
Constructor Detail
-
AbstractBeanIntrospection
protected AbstractBeanIntrospection(@NonNull java.lang.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 java.lang.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 Detail
-
getConstructor
public BeanConstructor<T> getConstructor()
- Specified by:
getConstructor
in interfaceBeanIntrospection<T>
- Returns:
- The bean constructor.
-
getConstructorAnnotationMetadata
protected AnnotationMetadata getConstructorAnnotationMetadata()
- Returns:
- Annotation metadata for the constructor.
- Since:
- 3.0.0
-
getIndexedProperty
@NonNull public java.util.Optional<BeanProperty<T,java.lang.Object>> getIndexedProperty(@NonNull java.lang.Class<? extends java.lang.annotation.Annotation> annotationType, @NonNull java.lang.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:
Introspected.indexed()
-
instantiate
@NonNull public T instantiate(boolean strictNullable, java.lang.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
@NonNull public java.util.Optional<BeanProperty<T,java.lang.Object>> getProperty(@NonNull java.lang.String name)
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
public int propertyIndexOf(java.lang.String name)
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 java.util.Collection<BeanProperty<T,java.lang.Object>> getIndexedProperties(@NonNull java.lang.Class<? extends java.lang.annotation.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:
Introspected.indexed()
-
getAnnotationMetadata
public AnnotationMetadata getAnnotationMetadata()
Description copied from interface:AnnotationMetadataProvider
Supplies the metadata. Defaults toAnnotationMetadata.EMPTY_METADATA
.- Specified by:
getAnnotationMetadata
in interfaceAnnotationMetadataProvider
- Returns:
- The
AnnotationMetadata
-
getBeanProperties
@NonNull public java.util.Collection<BeanProperty<T,java.lang.Object>> getBeanProperties()
- Specified by:
getBeanProperties
in interfaceBeanIntrospection<T>
- Returns:
- A immutable collection of properties.
-
getBeanType
@NonNull public java.lang.Class<T> getBeanType()
Description copied from interface:BeanIntrospection
The bean type.- Specified by:
getBeanType
in interfaceBeanIntrospection<T>
- Returns:
- The bean type
-
instantiateInternal
@Internal protected abstract T instantiateInternal(java.lang.Object[] arguments)
Reflection free bean instantiation implementation for the given arguments.- Parameters:
arguments
- The arguments- Returns:
- The bean
-
addProperty
@Internal protected final void addProperty(@NonNull BeanProperty<T,java.lang.Object> property)
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
@Internal protected final void addMethod(@NonNull BeanMethod<T,java.lang.Object> method)
Adds a method to the introspection. Used by generated byte code for subclasses and not for public consumption.- Parameters:
method
- The property.
-
getBeanMethods
@NonNull public java.util.Collection<BeanMethod<T,java.lang.Object>> 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 java.lang.Class<? extends java.lang.annotation.Annotation> annotationType, @NonNull java.lang.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 java.lang.Class<? extends java.lang.annotation.Annotation> annotationType, @NonNull java.lang.String propertyName, @Nullable java.lang.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
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-