Class AnnotationUtils

java.lang.Object
org.apache.juneau.commons.utils.AnnotationUtils

public class AnnotationUtils extends Object
Annotation utilities.
  • Constructor Details

  • Method Details

    • equals

      public static boolean equals(Annotation a1, Annotation a2)
      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, null returns false unless both are null
      a2 - the second Annotation to compare, null returns false unless both are null
      Returns:
      true if the two annotations are equal or both null
    • hash

      public static int hash(Annotation a)
      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:
      RuntimeException - if an Exception is encountered during annotation member access
      IllegalStateException - if an annotation method invocation returns null
    • 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 Annotation annotation = ...; // 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.