public final class JavaParserUtils extends Object
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.
| Modifier and Type | Method and Description |
|---|---|
static String |
getAlias(AnnotatedElement element,
Supplier<String> defaultValue)
Searches the given
element for any of the @Alias annotations. |
static String |
getAlias(Class<?> clazz) |
static String |
getAlias(Field field) |
static String |
getAlias(Function<Class<? extends Annotation>,Annotation> annotationMapper,
Supplier<String> defaultValue)
Runs the
annotationMapper through the @Alias annotations. |
static Optional<Boolean> |
getExclusiveOptionalsIsOneRequired(Class<?> type) |
static Optional<org.mule.runtime.api.meta.ExpressionSupport> |
getExpressionSupport(AnnotatedElement element) |
static Optional<org.mule.runtime.api.meta.ExpressionSupport> |
getExpressionSupport(Function<Class<? extends Annotation>,? extends Annotation> mapper) |
static Optional<Class<?>> |
getNullSafeDefaultImplementedType(Field field) |
static boolean |
isConfigOverride(Field field) |
static <R extends Annotation,S extends Annotation,T> |
mapReduceAnnotation(Class<?> type,
Class<R> legacyAnnotationClass,
Class<S> sdkAnnotationClass,
Function<R,T> legacyAnnotationMapping,
Function<S,T> sdkAnnotationMapping) |
static <R extends Annotation,S extends Annotation,T> |
mapReduceAnnotation(Element element,
Class<R> legacyAnnotationClass,
Class<S> sdkAnnotationClass,
Function<R,T> legacyAnnotationMapping,
Function<S,T> sdkAnnotationMapping)
Monad for extracting information from an
Element which might be annotated with two different annotations of similar
semantics. |
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 |
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 |
static org.mule.runtime.api.meta.ExternalLibraryType |
toMuleApi(org.mule.sdk.api.meta.ExternalLibraryType type)
Transforms an sdk-api
ExternalLibraryType into a mule-api ExternalLibraryType |
public static String getAlias(Field field)
field - a java Field@Alias annotationspublic static String getAlias(Class<?> clazz)
clazz - a Java class@Alias annotationspublic static String getAlias(AnnotatedElement element, Supplier<String> defaultValue)
element for any of the @Alias annotations. If any are found, the resolved alias is
returned. Otherwise, the defaultValue output is returnedelement - an annotated elementdefaultValue - a default value supplierpublic static String getAlias(Function<Class<? extends Annotation>,Annotation> annotationMapper, Supplier<String> defaultValue)
annotationMapper through the @Alias annotations. If any are found, the resolved alias is returned.
Otherwise, the defaultValue output is returnedannotationMapper - a function which encapsulates the annotation resolutiondefaultValue - a default value supplierpublic static Optional<org.mule.runtime.api.meta.ExpressionSupport> getExpressionSupport(AnnotatedElement element)
element - an Annotated elementExpressionSupport defined for the element, if defined. Optional.empty() otherwise.public static Optional<org.mule.runtime.api.meta.ExpressionSupport> getExpressionSupport(Function<Class<? extends Annotation>,? extends Annotation> mapper)
mapper - function which encapsulates annotation resolutionExpressionSupport defined for the element, if defined. Optional.empty() otherwise.public static boolean isConfigOverride(Field field)
field - a java Fieldtrue if the field is annotated with ConfigOverride or
ConfigOverridepublic static Optional<Boolean> getExclusiveOptionalsIsOneRequired(Class<?> type)
public static Optional<Class<?>> getNullSafeDefaultImplementedType(Field field)
public static <R extends Annotation,S extends Annotation,T> Optional<T> mapReduceAnnotation(Element element, Class<R> legacyAnnotationClass, Class<S> sdkAnnotationClass, Function<R,T> legacyAnnotationMapping, Function<S,T> sdkAnnotationMapping)
Element 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
R - Legacy annotation's generic typeS - New annotation's generic typeT - Output generic typeelement - the annotated elementlegacyAnnotationClass - the legacy annotation typesdkAnnotationClass - the new annotation typelegacyAnnotationMapping - mapping function for the legacy annotationsdkAnnotationMapping - mapping function for the new annotationpublic 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)
public static org.mule.runtime.api.meta.ExpressionSupport toMuleApi(org.mule.sdk.api.meta.ExpressionSupport support)
ExpressionSupport into a mule-api ExpressionSupportsupport - an sdk-api representation of the expression support semanticIllegalModelDefinitionException - if no equivalent semantic found.public static org.mule.runtime.api.meta.Category toMuleApi(org.mule.sdk.api.meta.Category category)
Category into a mule-api Categorycategory - an sdk-api representation of the Category semanticIllegalModelDefinitionException - if no equivalent semantic found.public static org.mule.runtime.api.meta.ExternalLibraryType toMuleApi(org.mule.sdk.api.meta.ExternalLibraryType type)
ExternalLibraryType into a mule-api ExternalLibraryTypetype - an sdk-api representation of the library type semanticIllegalModelDefinitionException - if no equivalent semantic found.Copyright © 2022 MuleSoft, Inc.. All rights reserved.