Class JavaParserUtils
java.lang.Object
org.mule.runtime.extension.internal.loader.util.JavaParserUtils
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 Summary
Modifier and TypeMethodDescriptionstatic Stringstatic StringgetAlias(AnnotatedElement element, Supplier<String> defaultValue) Searches the givenelementfor any of the@Aliasannotations.static StringgetExclusiveOptionalsIsOneRequired(Class<?> type) static Optional<org.mule.runtime.api.meta.ExpressionSupport>getExpressionSupport(AnnotatedElement element) static booleanisConfigOverride(Field field) 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 aClasswhich might be annotated with two different annotations of similar semantics.static org.mule.runtime.api.meta.CategorytoMuleApi(org.mule.sdk.api.meta.Category category) Transforms an sdk-apiCategoryinto a mule-apiCategorystatic org.mule.runtime.api.meta.ExpressionSupporttoMuleApi(org.mule.sdk.api.meta.ExpressionSupport support) Transforms an sdk-apiExpressionSupportinto a mule-apiExpressionSupport
-
Method Details
-
getAlias
- Parameters:
field- a java Field- Returns:
- the field's alias, as defined by any of the
@Aliasannotations
-
getAlias
- Parameters:
clazz- a Java class- Returns:
- the class alias, as defined by any of the
@Aliasannotations
-
getAlias
Searches the givenelementfor any of the@Aliasannotations. If any are found, the resolved alias is returned. Otherwise, thedefaultValueoutput is returned- Parameters:
element- an annotated elementdefaultValue- 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
ExpressionSupportdefined for the element, if defined.Optional.empty()otherwise.
-
isConfigOverride
- Parameters:
field- a java Field- Returns:
trueif the field is annotated withConfigOverrideorConfigOverride
-
getExclusiveOptionalsIsOneRequired
-
getNullSafeDefaultImplementedType
-
mapReduceAnnotation
public static <R extends Annotation,S extends Annotation, Optional<T> mapReduceAnnotationT> (Class<?> type, Class<R> legacyAnnotationClass, Class<S> sdkAnnotationClass, Function<R, T> legacyAnnotationMapping, Function<S, T> sdkAnnotationMapping) Monad for extracting information from aClasswhich 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 typeS- New annotation's generic typeT- Output generic type- Parameters:
type- the annotated classlegacyAnnotationClass- the legacy annotation typesdkAnnotationClass- the new annotation typelegacyAnnotationMapping- mapping function for the legacy annotationsdkAnnotationMapping- 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-apiExpressionSupportinto a mule-apiExpressionSupport- 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-apiCategoryinto a mule-apiCategory- Parameters:
category- an sdk-api representation of the Category semantic- Returns:
- the transformed value
- Throws:
IllegalModelDefinitionException- if no equivalent semantic found.
-