@Documented @Retention(value=RUNTIME) @Target(value={TYPE,ANNOTATION_TYPE}) public @interface Introspected
BeanIntrospection
at compilation time.
Typically to produce a BeanIntrospection
one simply annotates a class with this annotation.
@Introspected public class MyBean { ... }
An alternative approach is to use a AnnotationMapper
to enable introspection for existing annotations such as javax.persistence.Entity
.
If the classes you wish to introspect are already compiled then this annotation can be used on another class (doesn't matter which, but typically on a configuration class) to specify which existing compiled classes to produce BeanIntrospection
instances for either through the classes()
method or the packages()
method. The latter uses compile time package scanning and for the moment is regarded as Experimental
.
@Introspected(classes=MyBean.class) public class MyConfiguration { ... }
BeanIntrospection
,
BeanIntrospector
Modifier and Type | Optional Element and Description |
---|---|
boolean |
annotationMetadata
Whether annotation metadata should be included in the inspection results.
|
Class<?>[] |
classes
By default
Introspected applies to the class it is applied on. |
Class<? extends Annotation>[] |
excludedAnnotations
The annotation types that if present on the property cause the property to be excluded from results.
|
String[] |
excludes
The property names to excludes.
|
Class<? extends Annotation>[] |
includedAnnotations
The annotation types that if present on the property cause only the properties with the specified annotation to be included in the result.
|
String[] |
includes
The property names to include.
|
Introspected.IndexedAnnotation[] |
indexed
The annotation types that should be indexed for lookup via
BeanIntrospection.getIndexedProperties(Class) or BeanIntrospection.getIndexedProperty(Class, String) if Introspected.IndexedAnnotation.member() is specified. |
String[] |
packages
By default
Introspected applies to the class it is applied on. |
public abstract Class<?>[] classes
Introspected
applies to the class it is applied on. However if classes are specified
introspections will instead be generated for each class specified. This is useful in cases where you cannot
alter the source code and wish to generate introspections for already compiled classes.public abstract String[] packages
By default Introspected
applies to the class it is applied on. However if packages are specified
introspections will instead be generated for each classes in the given package. Note this only applies to already compiled
classes, and classpath scanning will be used to find them. If the class is not compiled then apply the annotation directly
to the classs instead.
Must be specified in combination with includedAnnotations()
public abstract String[] includes
public abstract String[] excludes
public abstract Class<? extends Annotation>[] excludedAnnotations
public abstract Class<? extends Annotation>[] includedAnnotations
public abstract boolean annotationMetadata
public abstract Introspected.IndexedAnnotation[] indexed
BeanIntrospection.getIndexedProperties(Class)
or BeanIntrospection.getIndexedProperty(Class, String)
if Introspected.IndexedAnnotation.member()
is specified.
Property lookup indexing allows building indexes at compilation time for performing reverse property lookups. Consider for example a property with an annotation such as @Column(name="foo_bar"
. To lookup the property by "foo_bar" you can specify:
@Introspected( indexed = @IndexedAnnotation(annotation=Column.class, member="name") ) public class MyBean { ... }
With the above in place a reverse lookup on the column can be done using BeanIntrospection.getIndexedProperty(Class, String)
:
BeanProperty property = introspection.getIndexedProperty(Column.class, "foo_bar").orElse(null);