public class Annotations
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
(package private) static class |
Annotations.AnnotationChecker
Checks for the presence of annotations.
|
private static class |
Annotations.AnnotationToStringConfig |
private static interface |
Annotations.TestAnnotation |
Modifier and Type | Field and Description |
---|---|
private static Annotations.AnnotationToStringConfig |
ANNOTATION_TO_STRING_CONFIG |
private static Annotations.AnnotationChecker |
bindingAnnotationChecker |
private static com.google.common.cache.LoadingCache<java.lang.Class<? extends java.lang.annotation.Annotation>,java.lang.annotation.Annotation> |
cache |
private static com.google.common.base.Joiner.MapJoiner |
JOINER |
private static Annotations.AnnotationChecker |
scopeChecker |
Constructor and Description |
---|
Annotations() |
Modifier and Type | Method and Description |
---|---|
private static boolean |
annotationEquals(java.lang.Class<? extends java.lang.annotation.Annotation> type,
java.util.Map<java.lang.String,java.lang.Object> members,
java.lang.Object other)
Implements
Annotation.equals(java.lang.Object) . |
private static int |
annotationHashCode(java.lang.Class<? extends java.lang.annotation.Annotation> type,
java.util.Map<java.lang.String,java.lang.Object> members)
Implements
Annotation.hashCode() . |
private static java.lang.String |
annotationToString(java.lang.Class<? extends java.lang.annotation.Annotation> type,
java.util.Map<java.lang.String,java.lang.Object> members)
Implements
Annotation.toString() . |
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 . |
(package private) static boolean |
containsComponentAnnotation(java.lang.annotation.Annotation[] annotations) |
private static Annotations.AnnotationToStringConfig |
determineAnnotationToStringConfig() |
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.
|
private static <T extends java.lang.annotation.Annotation> |
generateAnnotationImpl(java.lang.Class<T> annotationType) |
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.
|
private static com.google.common.collect.ImmutableMap<java.lang.String,java.lang.Object> |
resolveMembers(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType) |
private static final com.google.common.cache.LoadingCache<java.lang.Class<? extends java.lang.annotation.Annotation>,java.lang.annotation.Annotation> cache
private static final com.google.common.base.Joiner.MapJoiner JOINER
private static final Annotations.AnnotationToStringConfig ANNOTATION_TO_STRING_CONFIG
private static final Annotations.AnnotationChecker scopeChecker
private static final Annotations.AnnotationChecker bindingAnnotationChecker
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)
private static <T extends java.lang.annotation.Annotation> T generateAnnotationImpl(java.lang.Class<T> annotationType)
private static com.google.common.collect.ImmutableMap<java.lang.String,java.lang.Object> resolveMembers(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
private static boolean annotationEquals(java.lang.Class<? extends java.lang.annotation.Annotation> type, java.util.Map<java.lang.String,java.lang.Object> members, java.lang.Object other) throws java.lang.Exception
Annotation.equals(java.lang.Object)
.java.lang.Exception
private static int annotationHashCode(java.lang.Class<? extends java.lang.annotation.Annotation> type, java.util.Map<java.lang.String,java.lang.Object> members) throws java.lang.Exception
Annotation.hashCode()
.java.lang.Exception
private static java.lang.String annotationToString(java.lang.Class<? extends java.lang.annotation.Annotation> type, java.util.Map<java.lang.String,java.lang.Object> members) throws java.lang.Exception
Annotation.toString()
.java.lang.Exception
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)
static boolean containsComponentAnnotation(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.
private static Annotations.AnnotationToStringConfig determineAnnotationToStringConfig()
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
ErrorsException
public 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)