Annotation 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 { ... }
- Since:
- 1.1
- Author:
- graemerocher
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
The access type for bean properties.static @interface
Allow pre-computed indexes for property lookups based on an annotation and a member.static @interface
Configuration for an introspection builder.static enum
Visibility policy for bean properties and fields. -
Optional Element Summary
Modifier and TypeOptional ElementDescriptionThe default access type isIntrospected.AccessKind.METHOD
which treats only public JavaBean getters or Java record components as properties.boolean
Whether annotation metadata should be included in the inspection results.Allows specifying a builder for the introspection.Class<?>[]
By defaultIntrospected
applies to the class it is applied on.String[]
Alternative way to specify the value for `classes` when the class cannot be referenced.Class<? extends Annotation>[]
The annotation types that if present on the property cause the property to be excluded from results.String[]
The property names to excludes.boolean
If the introspection should ignore a setter with a different type than a getter.Class<? extends Annotation>[]
The annotation types that if present on the property cause only the properties with the specified annotation to be included in the result.String[]
The property names to include.The annotation types that should be indexed for lookup viaBeanIntrospection.getIndexedProperties(Class)
orBeanIntrospection.getIndexedProperty(Class, String)
ifIntrospected.IndexedAnnotation.member()
is specified.String[]
By defaultIntrospected
applies to the class it is applied on.Allows specifying the visibility policy to use to control which fields and methods are included. -
Field Summary
Modifier and TypeFieldDescriptionstatic final Introspected.AccessKind[]
The default values for the access kind attribute.static final Introspected.Visibility[]
The default values for the visibility attribute.
-
Field Details
-
DEFAULT_ACCESS_KIND
The default values for the access kind attribute. -
DEFAULT_VISIBILITY
The default values for the visibility attribute.
-
-
Element Details
-
classes
Class<?>[] classesBy 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:
- {}
-
classNames
String[] classNamesAlternative way to specify the value for `classes` when the class cannot be referenced.- Returns:
- The class names to generate introspections for
- Default:
- {}
-
accessKind
Introspected.AccessKind[] accessKindThe 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:
- {METHOD}
-
visibility
Introspected.Visibility[] visibilityAllows specifying the visibility policy to use to control which fields and methods are included.- Returns:
- The visibility policies
- Since:
- 3.2.0
- Default:
- {DEFAULT}
-
packages
String[] packagesBy 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:
- {}
-
includes
String[] includesThe property names to include. Defaults to all properties.- Returns:
- The names of the properties
- Default:
- {}
-
excludes
String[] excludesThe property names to excludes. Defaults to excluding none.- Returns:
- The names of the properties
- Default:
- {}
-
excludedAnnotations
Class<? extends Annotation>[] excludedAnnotationsThe annotation types that if present on the property cause the property to be excluded from results.- Returns:
- The annotation types
- Default:
- {}
-
includedAnnotations
Class<? extends Annotation>[] includedAnnotationsThe annotation types that if present on the property cause only the properties with the specified annotation to be included in the result.- Returns:
- The annotation types
- Default:
- {}
-
annotationMetadata
boolean annotationMetadataWhether annotation metadata should be included in the inspection results.- Returns:
- True if annotation metadata should be included.
- Default:
- true
-
indexed
Introspected.IndexedAnnotation[] indexedThe 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:
- {}
-
withPrefix
String withPrefix- Returns:
- The prefix used for copy constructor invoking methods on immutable types. The default is "with".
- Since:
- 2.3.0
- Default:
- "with"
-
targetPackage
String targetPackage- Returns:
- The package to write introspections to. By default, uses the class package.
- Since:
- 3.9.0
- Default:
- ""
-
ignoreSettersWithDifferingType
If the introspection should ignore a setter with a different type than a getter. NOTE: Access the correct a read/write type by usingBeanIntrospection.getBeanWriteProperties()
/BeanIntrospection.getBeanReadProperties()
()}- Returns:
- true if to ignore.
- Since:
- 4.4.0
- Default:
- true
-
builder
Allows specifying a builder for the introspection.- Returns:
- The builder definition for the introspection.
- Since:
- 4.1.0
- Default:
- @io.micronaut.core.annotation.Introspected.IntrospectionBuilder
-