public class Annotations
extends java.lang.Object
| Constructor and Description |
|---|
Annotations() |
| Modifier and Type | Method and Description |
|---|---|
static java.lang.annotation.Annotation |
canonicalizeIfNamed(java.lang.annotation.Annotation annotation)
If the annotation is an instance of
javax.inject.Named, canonicalizes to
com.google.guice.name.Named. |
static java.lang.Class<? extends java.lang.annotation.Annotation> |
canonicalizeIfNamed(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
If the annotation is the class
javax.inject.Named, canonicalizes to
com.google.guice.name.Named. |
static void |
checkForMisplacedScopeAnnotations(java.lang.Class<?> type,
java.lang.Object source,
Errors errors)
Adds an error if there is a misplaced annotations on
type. |
static java.lang.annotation.Annotation |
findBindingAnnotation(Errors errors,
java.lang.reflect.Member member,
java.lang.annotation.Annotation[] annotations)
Returns the binding annotation on
member, or null if there isn't one. |
static java.lang.Class<? extends java.lang.annotation.Annotation> |
findScopeAnnotation(Errors errors,
java.lang.annotation.Annotation[] annotations)
Returns the scoping annotation, or null if there isn't one.
|
static java.lang.Class<? extends java.lang.annotation.Annotation> |
findScopeAnnotation(Errors errors,
java.lang.Class<?> implementation)
Returns the scope annotation on
type, or null if none is specified. |
static <T extends java.lang.annotation.Annotation> |
generateAnnotation(java.lang.Class<T> annotationType)
Generates an Annotation for the annotation class.
|
static Key<?> |
getKey(TypeLiteral<?> type,
java.lang.reflect.Member member,
java.lang.annotation.Annotation[] annotations,
Errors errors)
Gets a key for the given type, member and annotations.
|
static boolean |
isAllDefaultMethods(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType) |
static boolean |
isBindingAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
Returns true if annotations of the specified type are binding annotations.
|
static boolean |
isMarker(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
Returns
true if the given annotation type has no attributes. |
static boolean |
isRetainedAtRuntime(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
Returns true if the given annotation is retained at runtime.
|
static boolean |
isScopeAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType) |
static java.lang.String |
memberValueString(java.lang.String value)
Returns
value, quoted if annotation implementations quote their member values. |
static java.lang.String |
memberValueString(java.lang.String memberName,
java.lang.Object value)
Returns string representation of the annotation memeber.
|
static java.lang.String |
nameOf(Key<?> key)
Returns the name the binding should use.
|
public static boolean isMarker(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
true if the given annotation type has no attributes.public static boolean isAllDefaultMethods(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
public static <T extends java.lang.annotation.Annotation> T generateAnnotation(java.lang.Class<T> annotationType)
public static boolean isRetainedAtRuntime(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
public static java.lang.Class<? extends java.lang.annotation.Annotation> findScopeAnnotation(Errors errors, java.lang.Class<?> implementation)
type, or null if none is specified.public static java.lang.Class<? extends java.lang.annotation.Annotation> findScopeAnnotation(Errors errors, java.lang.annotation.Annotation[] annotations)
public static java.lang.String memberValueString(java.lang.String value)
value, quoted if annotation implementations quote their member values. In Java
9, annotations quote their string members.public static java.lang.String memberValueString(java.lang.String memberName,
java.lang.Object value)
The value of the member is prefixed with `memberName=` unless the runtime omits the member name. The value of the member is quoted if annotation implementations quote their member values and the value type is String.
In Java 9, annotations quote their string members and in Java 15, the member name is omitted.
public static boolean isScopeAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
public static void checkForMisplacedScopeAnnotations(java.lang.Class<?> type,
java.lang.Object source,
Errors errors)
type. Scoping annotations are not
allowed on abstract classes or interfaces.public static Key<?> getKey(TypeLiteral<?> type, java.lang.reflect.Member member, java.lang.annotation.Annotation[] annotations, Errors errors) throws ErrorsException
ErrorsExceptionpublic static java.lang.annotation.Annotation findBindingAnnotation(Errors errors, java.lang.reflect.Member member, java.lang.annotation.Annotation[] annotations)
member, or null if there isn't one.public static boolean isBindingAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
public static java.lang.annotation.Annotation canonicalizeIfNamed(java.lang.annotation.Annotation annotation)
javax.inject.Named, canonicalizes to
com.google.guice.name.Named. Returns the given annotation otherwise.public static java.lang.Class<? extends java.lang.annotation.Annotation> canonicalizeIfNamed(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
javax.inject.Named, canonicalizes to
com.google.guice.name.Named. Returns the given annotation class otherwise.public static java.lang.String nameOf(Key<?> key)