Class MessagingAnnotationUtils

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

public final class MessagingAnnotationUtils
extends java.lang.Object
Utility methods to support annotation processing.
Since:
4.0
  • Method Summary

    Modifier and Type Method Description
    static java.lang.String endpointIdValue​(java.lang.reflect.Method method)
    Return the EndpointId.value() property, if present.
    static java.lang.reflect.Method findAnnotatedMethod​(java.lang.Object target, java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)  
    static java.lang.annotation.Annotation findMessagePartAnnotation​(java.lang.annotation.Annotation[] annotations, boolean payloads)
    Find the one of Payload, Header or Headers annotation from the provided annotations array.
    static boolean hasValue​(java.lang.Object value)  
    static <T> T resolveAttribute​(java.util.List<java.lang.annotation.Annotation> annotations, java.lang.String name, java.lang.Class<T> requiredType)
    Get the attribute value from the annotation hierarchy, returning the first non-empty value closest to the annotated method.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • resolveAttribute

      public static <T> T resolveAttribute​(java.util.List<java.lang.annotation.Annotation> annotations, java.lang.String name, java.lang.Class<T> requiredType)
      Get the attribute value from the annotation hierarchy, returning the first non-empty value closest to the annotated method. While traversing up the hierarchy, for string-valued attributes, an empty string is ignored. For array-valued attributes, an empty array is ignored. The overridden attribute must be the same type.
      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​(java.lang.Object value)
    • findAnnotatedMethod

      public static java.lang.reflect.Method findAnnotatedMethod​(java.lang.Object target, java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
    • findMessagePartAnnotation

      public static java.lang.annotation.Annotation findMessagePartAnnotation​(java.lang.annotation.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:
      org.springframework.messaging.MessagingException - if more than one of Payload, Header or Headers annotations are presented.
    • endpointIdValue

      public static java.lang.String endpointIdValue​(java.lang.reflect.Method method)
      Return the EndpointId.value() property, if present.
      Parameters:
      method - the methods.
      Returns:
      the id, or null.
      Since:
      5.0.4