Annotation instances.
This class contains various utility methods that make working with annotations simpler.
Annotation instances are always proxy objects; unfortunately
dynamic proxies cannot be depended upon to know how to implement certain
methods in the same manner as would be done by "natural" Annotations.
The methods presented in this class can be used to avoid that possibility. It
is of course also possible for dynamic proxies to actually delegate their
e.g. Annotation#equals(Object)/Annotation#hashCode()/
Annotation#toString() implementations to AnnotationUtils.
#ThreadSafe#
| Modifier and Type | Field and Description |
|---|---|
| private static final ToStringStyle | TO_STRING_STYLE
A style that prints annotations as recommended. |
| Access | Constructor and Description |
|---|---|
| public | AnnotationUtils()
Deprecated
TODO Make private in 4.0.
|
| Modifier and Type | Method and Description |
|---|---|
| private static boolean | Returns: a flag whether these arrays are equalthe first array a1, final Annotation[] the second array a2)Helper method for comparing two arrays of annotations. |
| private static boolean | Returns: a flag whether these objects are equalthe component type of the array componentType, final Object the first object o1, final Object the second object o2)Helper method for comparing two objects of an array type. |
| private static int | Returns: a hash code for the specified arraythe component type of the array componentType, final Object the array o)Helper method for generating a hash code for an array. |
| public static boolean | Returns: true if the two annotations are equal or both
nullthe first Annotation to compare, a1, final Annotation null returns
false unless both are nullthe second Annotation to compare, a2)null returns
false unless both are nullChecks if two annotations are equal using the criteria for equality
presented in the |
| public static int | Returns: the calculated hash codethe Annotation for a hash code calculation is desired, not
a)nullGenerate a hash code for the given annotation using the algorithm
presented in the |
| private static int | Returns: a hash code for this memberthe name of the member name, final Object the value of the member value)Helper method for generating a hash code for a member of an annotation. |
| public static boolean | Returns: true if the type is a valid type to use in an annotationthe type to check, type)nullChecks if the specified type is permitted as an annotation member. |
| private static boolean | Returns: a flag whether these objects are equalthe type of the objects to be compared type, final Object the first object o1, final Object the second object o2)Helper method for checking whether two objects of the given type are equal. |
| public static String | Returns: the standard string representation of an annotation, notnullthe annotation of which a string representation is desired a)Generate a string representation of an Annotation, as suggested by
|
| TO_STRING_STYLE | back to summary |
|---|---|
| private static final ToStringStyle TO_STRING_STYLE A style that prints annotations as recommended. | |
| AnnotationUtils | back to summary |
|---|---|
| public AnnotationUtils()
Deprecated TODO Make private in 4.0.
This constructor is public to permit tools that require a JavaBean instance to operate.
| |
| annotationArrayMemberEquals | back to summary |
|---|---|
| private static boolean annotationArrayMemberEquals(final Annotation[] a1, final Annotation[] a2) Helper method for comparing two arrays of annotations.
| |
| arrayMemberEquals | back to summary |
|---|---|
| private static boolean arrayMemberEquals(final Class<?> componentType, final Object o1, final Object o2) Helper method for comparing two objects of an array type. | |
| arrayMemberHash | back to summary |
|---|---|
| private static int arrayMemberHash(final Class<?> componentType, final Object o) Helper method for generating a hash code for an array. | |
| equals | back to summary |
|---|---|
| public static boolean equals(final Annotation a1, final Annotation a2) Checks if two annotations are equal using the criteria for equality
presented in the
| |
| hashCode | back to summary |
|---|---|
| public static int hashCode(final Annotation a) Generate a hash code for the given annotation using the algorithm
presented in the
| |
| hashMember | back to summary |
|---|---|
| private static int hashMember(final String name, final Object value) Helper method for generating a hash code for a member of an annotation. | |
| isValidAnnotationMemberType | back to summary |
|---|---|
| public static boolean isValidAnnotationMemberType(Class<?> type) Checks if the specified type is permitted as an annotation member. The Java language specification only permits certain types to be used
in annotations. These include
| |
| memberEquals | back to summary |
|---|---|
| private static boolean memberEquals(final Class<?> type, final Object o1, final Object o2) Helper method for checking whether two objects of the given type are equal. This method is used to compare the parameters of two annotation instances. | |
| toString | back to summary |
|---|---|
| public static String toString(final Annotation a) Generate a string representation of an Annotation, as suggested by
| |