Package io.micronaut.inject.beans
Class AbstractInitializableBeanIntrospection<B>
java.lang.Object
io.micronaut.inject.beans.AbstractInitializableBeanIntrospection<B>
- Type Parameters:
B
- The bean type
- All Implemented Interfaces:
AnnotationMetadata
,AnnotationMetadataDelegate
,AnnotationMetadataProvider
,AnnotationSource
,BeanInfo<B>
,BeanIntrospection<B>
,UnsafeBeanInstantiationIntrospection<B>
,ArgumentCoercible<B>
public abstract class AbstractInitializableBeanIntrospection<B>
extends Object
implements UnsafeBeanInstantiationIntrospection<B>
Abstract implementation of the
BeanIntrospection
interface. This class is subclasses at compilation time by generated byte code and should not be used directly.
Implementation is using method dispatch to access the bean instance.
- Since:
- 3.1
- Author:
- Denis Stepanov
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
Bean method compile-time data container.static final class
Bean property compile-time data container. -
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
AbstractInitializableBeanIntrospection
(Class<B> beanType, AnnotationMetadata annotationMetadata, AnnotationMetadata constructorAnnotationMetadata, Argument<?>[] constructorArguments, AbstractInitializableBeanIntrospection.BeanPropertyRef<Object>[] propertiesRefs, AbstractInitializableBeanIntrospection.BeanMethodRef<Object>[] methodsRefs) -
Method Summary
Modifier and TypeMethodDescriptionprotected <V> V
Triggers the invocation of the method at index.protected <V> V
dispatchOne
(int index, @NonNull Object target, @Nullable Object arg) Triggers the invocation of the method at index for a single argument call.boolean
findIndexedProperty
(@NonNull Class<? extends Annotation> annotationType, @NonNull String annotationValue) Get all the bean properties annotated for the given type.protected final Method
getAccessibleTargetMethodByIndex
(int index) FindMethod
representation at the method by index.Supplies the metadata.Returns theBeanMethod
instances for this introspection.protected Collection<BeanProperty<B,
Object>> getBeanPropertiesIndexedSubset
(int[] indexes) Returns subset of bean properties defined by an array of indexes.The bean type.Argument<?>[]
The constructor arguments needed to instantiate the bean.getIndexedProperties
(@NonNull Class<? extends Annotation> annotationType) Get all the bean properties annotated for the given annotation type.getIndexedProperty
(@NonNull Class<? extends Annotation> annotationType, @NonNull String annotationValue) Get all the bean properties annotated for the given type.getProperty
(@NonNull String name) Obtain a property by name.protected BeanProperty<B,
Object> getPropertyByIndex
(int index) Obtain a property by its index.protected abstract Method
getTargetMethodByIndex
(int index) FindMethod
representation at the method by index.int
hashCode()
Instantiates an instance of the bean, throwing an exception is instantiation is not possible.instantiate
(boolean strictNullable, Object... arguments) Instantiates an instance of the bean, throwing an exception is instantiation is not possible.protected abstract B
instantiateInternal
(@Nullable Object[] arguments) Reflection free bean instantiation implementation for the given arguments.instantiateUnsafe
(@NonNull Object... arguments) Instantiates an instance of the bean.int
propertyIndexOf
(String name) Obtain the property index position.toString()
protected final RuntimeException
unknownDispatchAtIndexException
(int index) Creates a new exception when the dispatch at index is not found.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
getIndexedProperty, getProperty, getPropertyNames, getRequiredProperty, instantiate
-
Constructor Details
-
AbstractInitializableBeanIntrospection
protected AbstractInitializableBeanIntrospection(Class<B> beanType, AnnotationMetadata annotationMetadata, AnnotationMetadata constructorAnnotationMetadata, Argument<?>[] constructorArguments, AbstractInitializableBeanIntrospection.BeanPropertyRef<Object>[] propertiesRefs, AbstractInitializableBeanIntrospection.BeanMethodRef<Object>[] methodsRefs)
-
-
Method Details
-
instantiateInternal
Reflection free bean instantiation implementation for the given arguments.- Parameters:
arguments
- The arguments- Returns:
- The bean
-
getPropertyByIndex
Obtain a property by its index.- Parameters:
index
- The index of the property- Returns:
- A bean property
-
propertyIndexOf
Description copied from interface:BeanIntrospection
Obtain the property index position.- Specified by:
propertyIndexOf
in interfaceBeanIntrospection<B>
- Parameters:
name
- The name of the property- Returns:
- A property index or -1 of not found.
-
getTargetMethodByIndex
FindMethod
representation at the method by index. Used byMethodReference.getTargetMethod()
.- Parameters:
index
- The index- Returns:
- The method
-
getAccessibleTargetMethodByIndex
FindMethod
representation at the method by index. Used byMethodReference.getTargetMethod()
.- Parameters:
index
- The index- Returns:
- The method
- Since:
- 3.8.5
-
dispatch
Triggers the invocation of the method at index.- Type Parameters:
V
- The result type- Parameters:
index
- The method indextarget
- The targetargs
- The arguments- Returns:
- The result
-
dispatchOne
@Nullable protected <V> V dispatchOne(int index, @NonNull @NonNull Object target, @Nullable @Nullable Object arg) Triggers the invocation of the method at index for a single argument call. Allowing to not wrap a single argument in an object array.- Type Parameters:
V
- The result type- Parameters:
index
- The method indextarget
- The targetarg
- The argument- Returns:
- The result
-
unknownDispatchAtIndexException
Creates a new exception when the dispatch at index is not found.- Parameters:
index
- The method index- Returns:
- The exception
-
findIndexedProperty
@Nullable public @Nullable BeanProperty<B,Object> findIndexedProperty(@NonNull @NonNull Class<? extends Annotation> annotationType, @NonNull @NonNull String annotationValue) Get all the bean properties annotated for the given type. Nullable result method version ofgetIndexedProperty(Class, String)
.- Parameters:
annotationType
- The annotation typeannotationValue
- The annotation value- Returns:
- A immutable collection of properties.
- See Also:
-
getIndexedProperties
@NonNull public @NonNull Collection<BeanProperty<B,Object>> getIndexedProperties(@NonNull @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<B>
- Parameters:
annotationType
- The annotation type- Returns:
- A immutable collection of properties.
- See Also:
-
getBeanPropertiesIndexedSubset
Returns subset of bean properties defined by an array of indexes.- Parameters:
indexes
- The indexes- Returns:
- a collection of bean properties
-
instantiate
Description copied from interface:BeanIntrospection
Instantiates an instance of the bean, throwing an exception is instantiation is not possible.- Specified by:
instantiate
in interfaceBeanIntrospection<B>
- Returns:
- An instance
- Throws:
InstantiationException
- If the bean cannot be instantiated or the arguments are not satisfied.
-
instantiate
@NonNull public B 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<B>
- 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.
-
instantiateUnsafe
Description copied from interface:UnsafeBeanInstantiationIntrospection
Instantiates an instance of the bean.- Specified by:
instantiateUnsafe
in interfaceUnsafeBeanInstantiationIntrospection<B>
- Parameters:
arguments
- The arguments required to instantiate bean.- Returns:
- An instance
-
getConstructor
- Specified by:
getConstructor
in interfaceBeanIntrospection<B>
- Returns:
- The bean constructor.
-
getConstructorArguments
Description copied from interface:BeanIntrospection
The constructor arguments needed to instantiate the bean.- Specified by:
getConstructorArguments
in interfaceBeanIntrospection<B>
- Returns:
- An argument array
-
getIndexedProperty
@NonNull public @NonNull Optional<BeanProperty<B,Object>> getIndexedProperty(@NonNull @NonNull Class<? extends Annotation> annotationType, @NonNull @NonNull String annotationValue) Description copied from interface:BeanIntrospection
Get all the bean properties annotated for the given type.- Specified by:
getIndexedProperty
in interfaceBeanIntrospection<B>
- Parameters:
annotationType
- The annotation typeannotationValue
- The annotation value- Returns:
- A immutable collection of properties.
- See Also:
-
getProperty
@NonNull public @NonNull Optional<BeanProperty<B,Object>> getProperty(@NonNull @NonNull String name) Description copied from interface:BeanIntrospection
Obtain a property by name.- Specified by:
getProperty
in interfaceBeanIntrospection<B>
- Parameters:
name
- The name of the property- Returns:
- A bean property if found
-
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<B>
- Returns:
- A immutable collection of properties.
-
getBeanType
Description copied from interface:BeanIntrospection
The bean type.- Specified by:
getBeanType
in interfaceBeanInfo<B>
- Specified by:
getBeanType
in interfaceBeanIntrospection<B>
- Returns:
- The bean type
-
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<B>
- Returns:
- A immutable collection of methods.
-
equals
-
hashCode
public int hashCode() -
toString
-