Class MessagingAnnotationUtils

java.lang.Object
org.springframework.integration.util.MessagingAnnotationUtils

public final class MessagingAnnotationUtils extends Object
Utility methods to support annotation processing.
Since:
4.0
Author:
Gary Russell, Dave Syer, Gunnar Hillert, Soby Chacko, Artem Bilan, Chris Bono, Ngoc Nhan
  • Method Details

    • resolveAttribute

      public static <T> T resolveAttribute(List<Annotation> annotations, String name, Class<T> requiredType)
      Get the attribute value from the annotation hierarchy, returning the first non-empty) value closest to the annotated method.
      Type Parameters:
      T - The type.
      Parameters:
      annotations - The meta-annotations in order (closest first).
      name - The attribute name.
      requiredType - The expected type.
      Returns:
      The value.
    • hasValue

      public static boolean hasValue(Object annotationValue)
      Determine if the value of a named attribute from an annotation instance contains an actual value.
      Parameters:
      annotationValue - the value of the annotation attribute
      Returns:
      false when annotationValue is null, an empty string, an empty array, or any annotation whose 'value' field is set to ValueConstants.DEFAULT_NONE - true otherwise
    • findAnnotatedMethod

      public static Method findAnnotatedMethod(Object target, Class<? extends Annotation> annotationType)
    • findMessagePartAnnotation

      public static Annotation findMessagePartAnnotation(Annotation[] annotations, boolean payloads)
      Find the one of Payload, Header or Headers annotation from the provided annotations array. Optionally also detects Payloads.
      Parameters:
      annotations - the annotations to scan.
      payloads - true if @Payloads should be detected.
      Returns:
      the matched annotation or null.
      Throws:
      MessagingException - if more than one of Payload, Header or Headers annotations are presented.
    • endpointIdValue

      @Nullable public static String endpointIdValue(Method method)
      Return the EndpointId.value() property, if present.
      Parameters:
      method - the methods.
      Returns:
      the id, or null.
      Since:
      5.0.4
    • endpointIdValue

      @Nullable public static String endpointIdValue(MergedAnnotations mergedAnnotations)
      Return the EndpointId.value() property, if present.
      Parameters:
      mergedAnnotations - the MergedAnnotations to analyze.
      Returns:
      the id, or null.
      Since:
      6.0
    • getAnnotationChain

      public static List<Annotation> getAnnotationChain(Annotation messagingAnnotation, Class<? extends Annotation> annotationType)
      Get a chain of its meta-annotations for the provided instance and expected type.
      Parameters:
      messagingAnnotation - the Annotation to take a chain for its meta-annotations.
      annotationType - the annotation type.
      Returns:
      the hierarchical list of annotations in top-bottom order.
      Since:
      6.0