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 |
---|---|
java.util.Collection<BeanProperty<T,java.lang.Object>> |
getBeanProperties() |
java.lang.Class<T> |
getBeanType()
The bean type.
|
default Argument<?>[] |
getConstructorArguments()
The constructor arguments needed to instantiate the bean.
|
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.
|
default java.util.Optional<BeanProperty<T,java.lang.Object>> |
getIndexedProperty(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
Get all the bean properties annotated for the given 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.
|
static <T2> BeanIntrospection<T2> |
getIntrospection(java.lang.Class<T2> type)
Obtains an introspection from the default
BeanIntrospector . |
default java.util.Optional<BeanProperty<T,java.lang.Object>> |
getProperty(java.lang.String name)
Obtain a property by name.
|
default <P> java.util.Optional<BeanProperty<T,P>> |
getProperty(java.lang.String name,
java.lang.Class<P> type)
Obtain a property by name and type.
|
default java.lang.String[] |
getPropertyNames()
The property names as an array.
|
default <P> BeanProperty<T,P> |
getRequiredProperty(java.lang.String name,
java.lang.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,
java.lang.Object... arguments)
Instantiates an instance of the bean, throwing an exception is instantiation is not possible.
|
default T |
instantiate(java.lang.Object... arguments)
Instantiates an instance of the bean, throwing an exception is instantiation is not possible.
|
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, getAnnotation, getAnnotation, getAnnotationNameByStereotype, getAnnotationNameByStereotype, getAnnotationNames, getAnnotationNamesByStereotype, getAnnotationNamesByStereotype, getAnnotationType, getAnnotationTypeByStereotype, getAnnotationTypeByStereotype, getAnnotationTypesByStereotype, getAnnotationValuesByType, getDeclaredAnnotation, getDeclaredAnnotation, getDeclaredAnnotationNameByStereotype, getDeclaredAnnotationNames, getDeclaredAnnotationNamesByStereotype, getDeclaredAnnotationTypeByStereotype, getDeclaredAnnotationTypeByStereotype, getDeclaredAnnotationValuesByType, getDefaultValue, getDefaultValue, getDefaultValue, getDefaultValue, getDefaultValues, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValues, getValues, hasAnnotation, hasAnnotation, hasDeclaredAnnotation, hasDeclaredAnnotation, hasDeclaredStereotype, hasDeclaredStereotype, hasDeclaredStereotype, hasSimpleAnnotation, hasSimpleDeclaredAnnotation, hasStereotype, hasStereotype, hasStereotype, hasStereotype, intValue, intValue, intValue, isAnnotationPresent, isDeclaredAnnotationPresent, isEmpty, isFalse, isFalse, isPresent, isPresent, isTrue, isTrue, longValue, longValue, stringValue, stringValue, stringValue, stringValue, stringValues, stringValues, synthesize, synthesizeAll, synthesizeAnnotationsByType, synthesizeDeclared, synthesizeDeclared, synthesizeDeclaredAnnotationsByType
getAnnotationMetadata
@NonNull java.util.Collection<BeanProperty<T,java.lang.Object>> getBeanProperties()
@NonNull java.util.Collection<BeanProperty<T,java.lang.Object>> getIndexedProperties(@NonNull java.lang.Class<? extends java.lang.annotation.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(java.lang.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, java.lang.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 java.lang.Class<T> getBeanType()
@NonNull java.util.Optional<BeanProperty<T,java.lang.Object>> getIndexedProperty(@NonNull java.lang.Class<? extends java.lang.annotation.Annotation> annotationType, @NonNull java.lang.String annotationValue)
annotationType
- The annotation typeannotationValue
- The annotation valueIntrospected.indexed()
@NonNull default java.util.Optional<BeanProperty<T,java.lang.Object>> getIndexedProperty(@NonNull java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
annotationType
- The annotation typeIntrospected.indexed()
@NonNull default Argument<?>[] getConstructorArguments()
@NonNull default java.util.Optional<BeanProperty<T,java.lang.Object>> getProperty(@NonNull java.lang.String name)
name
- The name of the property@NonNull default <P> BeanProperty<T,P> getRequiredProperty(@NonNull java.lang.String name, @NonNull java.lang.Class<P> type)
IntrospectionException
if the property is not present.P
- The property generic typename
- The nametype
- The type@NonNull default <P> java.util.Optional<BeanProperty<T,P>> getProperty(@NonNull java.lang.String name, @NonNull java.lang.Class<P> type)
P
- The property typename
- The name of the propertytype
- The property type to search for@NonNull default java.lang.String[] getPropertyNames()
static <T2> BeanIntrospection<T2> getIntrospection(java.lang.Class<T2> type)
BeanIntrospector
.T2
- The generic typetype
- The typeIntrospectionException
- If the introspection cannot be found or errors when loading