AnnotationUtils¶
- public class org.apache.commons.lang3.AnnotationUtils[source]¶
Helper methods for working with
Annotationinstances.This class contains various utility methods that make working with annotations simpler.
Annotationinstances 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 toAnnotationUtils.#ThreadSafe#
- Since:
3.0
Constructors¶
Deprecated. |
- @Deprecated public AnnotationUtils()[source]¶
Deprecated: TODO Make private in 4.0.
AnnotationUtilsinstances should NOT be constructed in standard programming. Instead, the class should be used statically.This constructor is public to permit tools that require a JavaBean instance to operate.
Methods¶
Checks if two annotations are equal using the criteria for equality presented in the |
|
Generate a hash code for the given annotation using the algorithm presented in the |
|
Tests whether the specified type is permitted as an annotation member. |
|
Generate a string representation of an Annotation, as suggested by |
- public static boolean equals(Annotation a1, Annotation a2)[source]¶
Checks if two annotations are equal using the criteria for equality presented in the
Annotation#equals(Object)API docs.- Parameters:
a1 – The first Annotation to compare,
nullreturnsfalseunless both arenulla2 – The second Annotation to compare,
nullreturnsfalseunless both arenull
- Returns:
trueif the two annotations areequalor bothnull
- public static int hashCode(Annotation a)[source]¶
Generate a hash code for the given annotation using the algorithm presented in the
Annotation#hashCode()API docs.- Parameters:
a – The Annotation for a hash code calculation is desired, not
null- Returns:
The calculated hash code
- Throws:
java.lang.RuntimeException – Thrown if an
Exceptionis encountered during annotation member access.java.lang.IllegalStateException – Thrown if an annotation method invocation returns
null.
- public static boolean isValidAnnotationMemberType(Class<?> type)[source]¶
Tests whether the specified type is permitted as an annotation member.
The Java language specification only permits certain types to be used in annotations. These include
String,Class, primitive types,Annotation,Enum, and single-dimensional arrays of these types.- Parameters:
type – The type to check,
null- Returns:
trueif the type is a valid type to use in an annotation
- public static String toString(Annotation a)[source]¶
Generate a string representation of an Annotation, as suggested by
Annotation#toString().- Parameters:
a – The annotation of which a string representation is desired
- Returns:
The standard string representation of an annotation, not
null