java.lang.Object
org.mule.runtime.extension.internal.loader.util.JavaParserUtils

public final class JavaParserUtils extends Object
Utilities for parsing Extensions defined through the Java language.

Use these methods when you're sure that you're parsing compiled classes. Do not use when the parsing context includes an AST (either java's or Mule's).

This class is not part of the API and should not be used by anyone (or anything) but the runtime. Backwards compatibility not guaranteed on this class.

Since:
1.5.0
  • Method Details

    • getAlias

      public static String getAlias(Field field)
      Parameters:
      field - a java Field
      Returns:
      the field's alias, as defined by any of the @Alias annotations
    • getAlias

      public static String getAlias(Class<?> clazz)
      Parameters:
      clazz - a Java class
      Returns:
      the class alias, as defined by any of the @Alias annotations
    • getAlias

      public static String getAlias(AnnotatedElement element, Supplier<String> defaultValue)
      Searches the given element for any of the @Alias annotations. If any are found, the resolved alias is returned. Otherwise, the defaultValue output is returned
      Parameters:
      element - an annotated element
      defaultValue - a default value supplier
      Returns:
      the resolved alias.
    • getExpressionSupport

      public static Optional<org.mule.runtime.api.meta.ExpressionSupport> getExpressionSupport(AnnotatedElement element)
      Parameters:
      element - an Annotated element
      Returns:
      the ExpressionSupport defined for the element, if defined. Optional.empty() otherwise.
    • isConfigOverride

      public static boolean isConfigOverride(Field field)
      Parameters:
      field - a java Field
      Returns:
      true if the field is annotated with ConfigOverride or ConfigOverride
    • getExclusiveOptionalsIsOneRequired

      public static Optional<Boolean> getExclusiveOptionalsIsOneRequired(Class<?> type)
    • getNullSafeDefaultImplementedType

      public static Optional<Class<?>> getNullSafeDefaultImplementedType(Field field)
    • mapReduceAnnotation

      public static <R extends Annotation, S extends Annotation, T> Optional<T> mapReduceAnnotation(Class<?> type, Class<R> legacyAnnotationClass, Class<S> sdkAnnotationClass, Function<R,T> legacyAnnotationMapping, Function<S,T> sdkAnnotationMapping)
      Monad for extracting information from a Class which might be annotated with two different annotations of similar semantics. Both annotations' types are reduced to a single output type.

      Simultaneous presence of both types will be considered an error

      Type Parameters:
      R - Legacy annotation's generic type
      S - New annotation's generic type
      T - Output generic type
      Parameters:
      type - the annotated class
      legacyAnnotationClass - the legacy annotation type
      sdkAnnotationClass - the new annotation type
      legacyAnnotationMapping - mapping function for the legacy annotation
      sdkAnnotationMapping - mapping function for the new annotation
      Returns:
      a reduced value
    • toMuleApi

      public static org.mule.runtime.api.meta.ExpressionSupport toMuleApi(org.mule.sdk.api.meta.ExpressionSupport support)
      Transforms an sdk-api ExpressionSupport into a mule-api ExpressionSupport
      Parameters:
      support - an sdk-api representation of the expression support semantic
      Returns:
      the transformed value
      Throws:
      IllegalModelDefinitionException - if no equivalent semantic found.
    • toMuleApi

      public static org.mule.runtime.api.meta.Category toMuleApi(org.mule.sdk.api.meta.Category category)
      Transforms an sdk-api Category into a mule-api Category
      Parameters:
      category - an sdk-api representation of the Category semantic
      Returns:
      the transformed value
      Throws:
      IllegalModelDefinitionException - if no equivalent semantic found.