Package org.apache.juneau.commons.utils
Class AnnotationUtils
java.lang.Object
org.apache.juneau.commons.utils.AnnotationUtils
Annotation utilities.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanequals(Annotation a1, Annotation a2) Checks if two annotations are equal using the criteria for equality presented in theAnnotation.equals(Object)API docs.static inthash(Annotation a) Generate a hash code for the given annotation using the algorithm presented in theAnnotation.hashCode()API docs.static Stream<Annotation>Returns a stream of nested annotations in a repeated annotation if the specified annotation is a repeated annotation, or a singleton stream with the same annotation if not.
-
Constructor Details
-
AnnotationUtils
public AnnotationUtils()
-
-
Method Details
-
equals
Checks if two annotations are equal using the criteria for equality presented in theAnnotation.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
-
hash
Generate a hash code for the given annotation using the algorithm presented in theAnnotation.hashCode()API docs.- Parameters:
a- the Annotation for a hash code calculation is desired, notnull- Returns:
- the calculated hash code
- Throws:
RuntimeException- if anExceptionis encountered during annotation member accessIllegalStateException- if an annotation method invocation returnsnull
-
streamRepeated
Returns a stream of nested annotations in a repeated annotation if the specified annotation is a repeated annotation, or a singleton stream with the same annotation if not.This method is a stream-based alternative to splitting repeated annotations that avoids creating intermediate arrays.
Example:
// Given an annotation that may be repeatable Annotationannotation = ...;// Stream individual annotations (expanded if repeatable) streamRepeated(annotation ) .forEach(a -> System.out .println(a ));- Parameters:
a- The annotation to split.- Returns:
- A stream of nested annotations, or a singleton stream with the same annotation if it's not repeated.
Never
null .
-