T
- The bean type@Immutable public interface BeanIntrospection<T> extends AnnotationMetadataDelegate
BeanIntrospection
is the result of compile time computation of a beans properties and annotation metadata.
This interface allows you to instantiate and read and write to bean properties without using reflection or caching reflective metadata, which is expensive from a memory consumption perspective.
BeanIntrospection
instances can be obtained either via getIntrospection(Class)
or via the BeanIntrospector
.
A BeanIntrospection
is only computed at compilation time if the class is annotated with Introspected
.
BeanIntrospector
,
Introspected
CLASS_NAME_SUFFIX, EMPTY_METADATA, VALUE_MEMBER
EMPTY
Modifier and Type | Method and Description |
---|---|
default Collection<BeanMethod<T,Object>> |
getBeanMethods()
Returns the
BeanMethod instances for this introspection. |
Collection<BeanProperty<T,Object>> |
getBeanProperties() |
Class<T> |
getBeanType()
The bean type.
|
default BeanConstructor<T> |
getConstructor() |
default Argument<?>[] |
getConstructorArguments()
The constructor arguments needed to instantiate the bean.
|
Collection<BeanProperty<T,Object>> |
getIndexedProperties(Class<? extends Annotation> annotationType)
Get all the bean properties annotated for the given annotation type.
|
default Optional<BeanProperty<T,Object>> |
getIndexedProperty(Class<? extends Annotation> annotationType)
Get all the bean properties annotated for the given type.
|
Optional<BeanProperty<T,Object>> |
getIndexedProperty(Class<? extends Annotation> annotationType,
String annotationValue)
Get all the bean properties annotated for the given type.
|
static <T2> BeanIntrospection<T2> |
getIntrospection(Class<T2> type)
Obtains an introspection from the default
BeanIntrospector . |
default Optional<BeanProperty<T,Object>> |
getProperty(String name)
Obtain a property by name.
|
default <P> Optional<BeanProperty<T,P>> |
getProperty(String name,
Class<P> type)
Obtain a property by name and type.
|
default String[] |
getPropertyNames()
The property names as an array.
|
default <P> BeanProperty<T,P> |
getRequiredProperty(String name,
Class<P> type)
Gets a property of the given name and type or throws
IntrospectionException if the property is not present. |
T |
instantiate()
Instantiates an instance of the bean, throwing an exception is instantiation is not possible.
|
T |
instantiate(boolean strictNullable,
Object... arguments)
Instantiates an instance of the bean, throwing an exception is instantiation is not possible.
|
default T |
instantiate(Object... arguments)
Instantiates an instance of the bean, throwing an exception is instantiation is not possible.
|
default int |
propertyIndexOf(String name)
Obtain the property index position.
|
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
getAnnotationMetadata
getAnnotationValuesByName, getAnnotationValuesByStereotype, getDeclaredAnnotationValuesByName, getValues, hasDeclaredStereotype, isAnnotationPresent, isDeclaredAnnotationPresent
@NonNull Collection<BeanProperty<T,Object>> getBeanProperties()
@NonNull Collection<BeanProperty<T,Object>> getIndexedProperties(@NonNull Class<? extends Annotation> annotationType)
Introspected.indexed()
by the given annotation,
then it will be included in the resulting list.annotationType
- The annotation typeIntrospected.indexed()
@NonNull T instantiate() throws InstantiationException
InstantiationException
- If the bean cannot be instantiated or the arguments are not satisfied.@NonNull default T instantiate(Object... arguments) throws InstantiationException
arguments
- The arguments required to instantiate bean. Should match the types returned by getConstructorArguments()
InstantiationException
- If the bean cannot be instantiated.@NonNull T instantiate(boolean strictNullable, Object... arguments) throws InstantiationException
strictNullable
- If true, require null parameters to be annotated with a nullable annotationarguments
- The arguments required to instantiate bean. Should match the types returned by getConstructorArguments()
InstantiationException
- If the bean cannot be instantiated.@NonNull Optional<BeanProperty<T,Object>> getIndexedProperty(@NonNull Class<? extends Annotation> annotationType, @NonNull String annotationValue)
annotationType
- The annotation typeannotationValue
- The annotation valueIntrospected.indexed()
@NonNull default Collection<BeanMethod<T,Object>> getBeanMethods()
BeanMethod
instances for this introspection.
The BeanMethod
instances are only those methods annotated with io.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 as BeanProperty
instances.
@NonNull default Optional<BeanProperty<T,Object>> getIndexedProperty(@NonNull Class<? extends Annotation> annotationType)
annotationType
- The annotation typeIntrospected.indexed()
@NonNull default Argument<?>[] getConstructorArguments()
@NonNull default Optional<BeanProperty<T,Object>> getProperty(@NonNull String name)
name
- The name of the propertydefault int propertyIndexOf(@NonNull String name)
name
- The name of the property@NonNull default <P> BeanProperty<T,P> getRequiredProperty(@NonNull String name, @NonNull Class<P> type)
IntrospectionException
if the property is not present.P
- The property generic typename
- The nametype
- The type@NonNull default <P> Optional<BeanProperty<T,P>> getProperty(@NonNull String name, @NonNull Class<P> type)
P
- The property typename
- The name of the propertytype
- The property type to search for@NonNull default String[] getPropertyNames()
@NonNull default BeanConstructor<T> getConstructor()
static <T2> BeanIntrospection<T2> getIntrospection(Class<T2> type)
BeanIntrospector
.T2
- The generic typetype
- The typeIntrospectionException
- If the introspection cannot be found or errors when loading