public final class Annotations
extends java.lang.Object
AnnotatedWildcardTypes,
AnnotatedParameterizedTypes, and AnnotatedArrayTypes.| Modifier and Type | Class and Description |
|---|---|
static class |
Annotations.AnnotationParser
A parser for
Annotations, and various related types. |
| Constructor and Description |
|---|
Annotations() |
| Modifier and Type | Method and Description |
|---|---|
static <T extends java.lang.annotation.Annotation> |
from(java.lang.Class<T> annotationClass)
Try to instantiate an instance of a given annotation type, with default
values for any properties.
|
static <T extends java.lang.annotation.Annotation> |
from(java.lang.Class<T> annotationClass,
AnnotationProperty... properties) |
static <T extends java.lang.annotation.Annotation> |
from(java.lang.Class<T> annotationClass,
java.util.Collection<? extends AnnotationProperty> properties) |
static <T extends java.lang.annotation.Annotation> |
from(java.lang.Class<T> annotationClass,
java.util.Map<java.lang.String,java.lang.Object> properties)
Instantiate an instance of a given annotation type, with the given mapping
from properties to their values.
|
static java.lang.annotation.Annotation |
fromString(java.lang.String typeString)
Create an Annotation instance from a parsed String.
|
static java.lang.annotation.Annotation |
fromString(java.lang.String typeString,
Imports imports)
Create an Annotation instance from a parsed String.
|
static java.util.stream.Stream<AnnotationProperty> |
getModifiedProperties(java.lang.annotation.Annotation annotation) |
static Annotations.AnnotationParser |
getParser()
Get the default annotation parser.
|
static Annotations.AnnotationParser |
getParser(Imports imports)
Get an annotation parser with knowledge of the given imports.
|
static java.util.stream.Stream<AnnotationProperty> |
getProperties(java.lang.annotation.Annotation annotation) |
protected static java.lang.StringBuilder |
toPropertyString(java.lang.Object object) |
protected static java.lang.StringBuilder |
toPropertyString(java.lang.Object object,
Imports imports) |
static java.lang.String |
toString(java.lang.annotation.Annotation annotation)
Give a canonical String representation of a given annotation.
|
static java.lang.String |
toString(java.lang.annotation.Annotation annotation,
Imports imports)
Give a canonical String representation of a given annotation.Provided class
and package imports allow the names of some classes to be output without
full package qualification.
|
public static java.lang.String toString(java.lang.annotation.Annotation annotation)
annotation - The annotation of which we wish to determine a string
representation.public static java.lang.String toString(java.lang.annotation.Annotation annotation,
Imports imports)
annotation - The annotation of which we wish to determine a string
representation.imports - Classes and packages for which full package qualification may be
omitted from output.protected static java.lang.StringBuilder toPropertyString(java.lang.Object object)
protected static java.lang.StringBuilder toPropertyString(java.lang.Object object,
Imports imports)
public static java.lang.annotation.Annotation fromString(java.lang.String typeString)
typeString - The String to parse.public static java.lang.annotation.Annotation fromString(java.lang.String typeString,
Imports imports)
typeString - The String to parse.imports - Classes and packages for which full package qualification may be
omitted from input.public static java.util.stream.Stream<AnnotationProperty> getProperties(java.lang.annotation.Annotation annotation)
public static java.util.stream.Stream<AnnotationProperty> getModifiedProperties(java.lang.annotation.Annotation annotation)
public static <T extends java.lang.annotation.Annotation> T from(java.lang.Class<T> annotationClass)
T - The type of the annotation to instantiateannotationClass - The type of the annotation to instantiatepublic static <T extends java.lang.annotation.Annotation> T from(java.lang.Class<T> annotationClass,
AnnotationProperty... properties)
public static <T extends java.lang.annotation.Annotation> T from(java.lang.Class<T> annotationClass,
java.util.Collection<? extends AnnotationProperty> properties)
public static <T extends java.lang.annotation.Annotation> T from(java.lang.Class<T> annotationClass,
java.util.Map<java.lang.String,java.lang.Object> properties)
T - The type of the annotation to instantiateannotationClass - The type of the annotation to instantiateproperties - A mapping from names of properties on the annotation to valuespublic static Annotations.AnnotationParser getParser()
public static Annotations.AnnotationParser getParser(Imports imports)
imports - A list of imports the annotation parser should be aware of