Annotation Type Introspected
-
@Documented @Retention(RUNTIME) @Target({TYPE,ANNOTATION_TYPE}) @Inherited public @interface Introspected
An annotation that indicates a type should produce aBeanIntrospection
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 asjavax.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 theclasses()
method or thepackages()
method. The latter uses compile time package scanning and for the moment is regarded asExperimental
.@Introspected(classes = MyBean.class) public class MyConfiguration { ... }
- Since:
- 1.1
- See Also:
BeanIntrospection
,BeanIntrospector
-
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description Introspected.AccessKind[]
accessKind
The default access type isIntrospected.AccessKind.METHOD
which treats only public JavaBean getters or Java record components as properties.boolean
annotationMetadata
Whether annotation metadata should be included in the inspection results.java.lang.Class<?>[]
classes
By defaultIntrospected
applies to the class it is applied on.java.lang.Class<? extends java.lang.annotation.Annotation>[]
excludedAnnotations
The annotation types that if present on the property cause the property to be excluded from results.java.lang.String[]
excludes
The property names to excludes.java.lang.Class<? extends java.lang.annotation.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.java.lang.String[]
includes
The property names to include.Introspected.IndexedAnnotation[]
indexed
The annotation types that should be indexed for lookup viaBeanIntrospection.getIndexedProperties(Class)
orBeanIntrospection.getIndexedProperty(Class, String)
ifIntrospected.IndexedAnnotation.member()
is specified.java.lang.String[]
packages
By defaultIntrospected
applies to the class it is applied on.java.lang.String
targetPackage
Introspected.Visibility[]
visibility
Allows specifying the visibility policy to use to control which fields and methods are included.java.lang.String
withPrefix
-
-
-
Element Detail
-
classes
java.lang.Class<?>[] classes
By defaultIntrospected
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.- Returns:
- The classes to generate introspections for
- Default:
- {}
-
-
-
accessKind
Introspected.AccessKind[] accessKind
The default access type is
Introspected.AccessKind.METHOD
which treats only public JavaBean getters or Java record components as properties. By specifyingIntrospected.AccessKind.FIELD
, public or package-protected fields will be used instead.If both
Introspected.AccessKind.FIELD
andIntrospected.AccessKind.METHOD
are specified then the order as they appear in the annotation will be used to determine whether the field or method will be used in the case where both exist.- Returns:
- The access type. Defaults to
Introspected.AccessKind.METHOD
- Since:
- 3.0
- Default:
- {io.micronaut.core.annotation.Introspected.AccessKind.METHOD}
-
-
-
visibility
Introspected.Visibility[] visibility
Allows specifying the visibility policy to use to control which fields and methods are included.- Returns:
- The visibility policies
- Since:
- 3.2.0
- Default:
- {io.micronaut.core.annotation.Introspected.Visibility.DEFAULT}
-
-
-
packages
java.lang.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()
- Returns:
- The packages to generate introspections for
- Default:
- {}
-
-
-
indexed
Introspected.IndexedAnnotation[] indexed
The annotation types that should be indexed for lookup viaBeanIntrospection.getIndexedProperties(Class)
orBeanIntrospection.getIndexedProperty(Class, String)
ifIntrospected.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);
- Returns:
- The indexed annotation types
- Default:
- {}
-
-