public final class IntrospectionUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static boolean |
assignableFromAny(Class<?> type,
Collection<Class<?>> matchingTypes)
Determines if the given
type is assignable from any of the matchingTypes |
static void |
checkInstantiable(Class<?> declaringClass) |
static void |
checkInstantiable(Class<?> declaringClass,
boolean requireDefaultConstructor) |
static Set<Class<?>> |
collectRelativeClasses(org.mule.metadata.api.model.MetadataType type,
ClassLoader extensionClassLoader)
Given a
MetadataType it adds all the Class that are related from that type. |
static List<Class<?>> |
findGenericsInSuperHierarchy(Class<?> type) |
static <T extends AnnotatedElement & Member> |
getAlias(T element)
Returns the
Alias name of the given element. |
static Optional<AnnotatedElement> |
getAnnotatedElement(org.mule.runtime.api.meta.model.declaration.fluent.BaseDeclaration<?> declaration) |
static List<Field> |
getAnnotatedFields(Class<?> clazz,
Class<? extends Annotation> annotationType) |
static <T extends Annotation> |
getAnnotation(Class<?> annotatedClass,
Class<T> annotationClass)
Looks for the annotation in the given class.
|
static Collection<Method> |
getApiMethods(Class<?> declaringClass) |
static Optional<org.mule.runtime.api.meta.model.connection.ConnectionProviderModel> |
getConnectionProviderModel(Class<? extends org.mule.runtime.api.connection.ConnectionProvider> connectionProvider,
List<org.mule.runtime.api.meta.model.connection.ConnectionProviderModel> allConnectionProviders)
Resolves the correspondent
ConnectionProviderModel for a given ConnectionProvider instance. |
static String |
getContainerName(AnnotatedElement container) |
static Optional<FieldSetter> |
getDefaultEncodingFieldSetter(Object target)
|
static Collection<Field> |
getExposedFields(Class<?> extensionType) |
static org.mule.runtime.api.meta.ExpressionSupport |
getExpressionSupport(AnnotatedElement object) |
static org.mule.runtime.api.meta.ExpressionSupport |
getExpressionSupport(org.mule.runtime.extension.api.annotation.Expression expressionAnnotation) |
static Optional<Field> |
getField(Class<?> clazz,
org.mule.runtime.api.meta.model.declaration.fluent.ParameterDeclaration parameterDeclaration) |
static Optional<Field> |
getField(Class<?> clazz,
org.mule.runtime.api.meta.model.parameter.ParameterModel parameterModel) |
static Optional<Field> |
getField(Class<?> clazz,
String name) |
static Optional<Field> |
getFieldByNameOrAlias(Class<?> clazz,
String nameOrAlias) |
static org.mule.metadata.api.model.MetadataType |
getFieldMetadataType(Field field,
org.mule.metadata.api.ClassTypeLoader typeLoader)
Returns a
MetadataType describing the given Field's type |
static List<Field> |
getFields(Class<?> clazz) |
static List<Field> |
getFieldsOfType(Class<?> introspectedType,
Class fieldType) |
static Set<Field> |
getFieldsWithGetters(Class<?> extensionType) |
static Object |
getFieldValue(Object object,
String fieldName)
Resolves and returns the field value of an object instance
|
static List<org.mule.metadata.api.model.MetadataType> |
getGenerics(Type type,
org.mule.metadata.api.ClassTypeLoader typeLoader) |
static String |
getGroupModelContainerName(org.mule.runtime.api.meta.model.parameter.ParameterGroupModel groupModel) |
static String |
getImplementingName(org.mule.runtime.api.meta.model.declaration.fluent.ParameterDeclaration parameterDeclaration)
Resolves the original name of a parameter before it was modified due to the usage of an Alias.
|
static String |
getImplementingName(org.mule.runtime.api.meta.model.parameter.ParameterModel parameterModel)
Resolves the original name of a parameter before it was modified due to the usage of an Alias.
|
static List<Class<?>> |
getInterfaceGenerics(Class<?> type,
Class<?> implementedInterface) |
static String |
getMemberName(org.mule.runtime.api.meta.model.EnrichableModel enrichableModel,
String defaultName) |
static org.mule.metadata.api.model.MetadataType |
getMetadataType(Class<?> type,
org.mule.metadata.api.ClassTypeLoader typeLoader)
Returns a
MetadataType representing the given Class type. |
static org.mule.metadata.api.model.MetadataType[] |
getMethodArgumentTypes(Method method,
org.mule.metadata.api.ClassTypeLoader typeLoader)
Returns an array of
MetadataType representing each of the given Method's argument types. |
static org.mule.metadata.api.model.MetadataType |
getMethodReturnAttributesType(Method method,
org.mule.metadata.api.ClassTypeLoader typeLoader)
Returns a
MetadataType representing the Result.getAttributes() that will be set after executing the given
method. |
static org.mule.metadata.api.model.MetadataType |
getMethodReturnType(Method method,
org.mule.metadata.api.ClassTypeLoader typeLoader)
Returns a
MetadataType representing the given Method's return type. |
static Collection<Method> |
getMethodsAnnotatedWith(Class<?> declaringClass,
Class<? extends Annotation> annotationType)
Returns all the methods in the
declaringClass which are annotated with annotationType, including those
declared in super classes. |
static Collection<Method> |
getMethodsAnnotatedWith(Class<?> declaringClass,
Class<? extends Annotation> annotationType,
boolean superClasses)
Returns all the methods in the
declaringClass which are annotated with annotationType |
static org.mule.runtime.api.util.Pair<org.springframework.core.ResolvableType,org.springframework.core.ResolvableType> |
getPagingProviderTypes(org.springframework.core.ResolvableType pagingProvider)
Introspects a
PagingProvider type and returns their generics. |
static Set<Class<?>> |
getParameterClasses(org.mule.runtime.api.meta.model.ExtensionModel extensionModel,
ClassLoader extensionClassLoader)
Traverses through all the
ParameterModels of the extensionModel and returns the classes that
are modeled by each parameter's Typed.getType(). |
static String |
getSourceName(Class<? extends org.mule.runtime.extension.api.runtime.source.Source> sourceType) |
static org.mule.metadata.api.model.MetadataType |
getSourceReturnType(Type returnType,
org.mule.metadata.api.ClassTypeLoader typeLoader)
Returns the
MetadataType for a source's output. |
static List<Type> |
getSuperClassGenerics(Class<?> type,
Class<?> superClass) |
static boolean |
hasDefaultConstructor(Class<?> clazz) |
static void |
injectComponentLocation(Object target,
org.mule.runtime.api.component.location.ComponentLocation componentLocation)
Introspects the
target object for a field of type ComponentLocation. |
static void |
injectDefaultEncoding(org.mule.runtime.api.meta.model.EnrichableModel model,
Object target,
String encoding)
Sets the
encoding value into the field of the target annotated DefaultEncoding if the model
contains the DeclaringMemberModelProperty property and the value is not null. |
static void |
injectDefaultEncoding(Object target,
String encoding)
Sets the
encoding value into the field of the target annotated DefaultEncoding (if present) |
static void |
injectFields(org.mule.runtime.api.meta.model.EnrichableModel model,
Object target,
String configName,
String encoding)
Sets the
configName into the field of the target annotated RefName (if it's present) and does the same for the
encoding and the field annotated with DefaultEncoding if the model contains the DeclaringMemberModelProperty |
static void |
injectFields(Object target,
String configName,
String encoding)
Sets the
configName into the field of the target annotated RefName (if it's present) and does the same for the
encoding and the field annotated with DefaultEncoding. |
static void |
injectRefName(Object target,
String configName)
Introspects the
target object for a field annotated with RefName. |
static boolean |
isInstantiable(Class<?> declaringClass) |
static boolean |
isInstantiable(Class<?> declaringClass,
boolean requireDefaultConstructor) |
static boolean |
isInstantiable(org.mule.metadata.api.model.MetadataType type) |
static boolean |
isLifecycle(Class<?> type)
Determines if the given
type implements any of the lifecycle annotations |
static boolean |
isLiteral(org.mule.metadata.api.model.MetadataType metadataType) |
static boolean |
isMultiLevelMetadataKeyId(Set<Class<? extends Annotation>> annotations,
org.mule.metadata.api.model.MetadataType parameterType)
Given a
Set of Annotation classes and a MetadataType that describes a component parameter, indicates if the
parameter is considered as a multilevel MetadataKeyId |
static boolean |
isParameterContainer(Set<Class<? extends Annotation>> annotations,
org.mule.metadata.api.model.MetadataType parameterType)
Given a
Set of annotation classes and a MetadataType of a component parameter, indicates if the parameter is
a parameter container. |
static boolean |
isParameterResolver(org.mule.metadata.api.model.MetadataType metadataType) |
static boolean |
isRequired(AccessibleObject object) |
static boolean |
isRequired(org.mule.runtime.api.meta.model.parameter.ParameterModel parameterModel,
boolean forceOptional) |
static boolean |
isTargetParameter(Set<org.mule.runtime.api.meta.model.ModelProperty> modelProperties) |
static boolean |
isTypedValue(org.mule.metadata.api.model.MetadataType metadataType) |
static boolean |
isVoid(org.mule.runtime.api.meta.model.ComponentModel componentModel) |
static boolean |
isVoid(Method method) |
static org.mule.runtime.api.metadata.DataType |
toDataType(org.mule.metadata.api.model.MetadataType metadataType)
Transforms a
MetadataType and generates the correspondent DataType |
public static org.mule.metadata.api.model.MetadataType getMetadataType(Class<?> type, org.mule.metadata.api.ClassTypeLoader typeLoader)
MetadataType representing the given Class type.type - the Class being introspectedtypeLoader - a ClassTypeLoader used to create the MetadataTypeMetadataTypepublic static org.mule.runtime.api.metadata.DataType toDataType(org.mule.metadata.api.model.MetadataType metadataType)
MetadataType and generates the correspondent DataTypemetadataType - to introspect a create a DataType from it.DataType based on the given MetadataTypepublic static org.mule.metadata.api.model.MetadataType getMethodReturnType(Method method, org.mule.metadata.api.ClassTypeLoader typeLoader)
MetadataType representing the given Method's return type. If the method returns an
Result, then it returns the type of the first generic. If the Result type is being used in its raw form, then
an AnyType will be returned.
If the method returns a collection of Result instances, then it will return an ArrayType which inner
value represent a Message which payload and attributes matches the types of the Result generics.
method - the Method being introspectedtypeLoader - a ClassTypeLoader used to create the MetadataTypeMetadataTypeIllegalArgumentException - is method is nullpublic static org.mule.metadata.api.model.MetadataType getSourceReturnType(Type returnType, org.mule.metadata.api.ClassTypeLoader typeLoader)
MetadataType for a source's output.
If the type is a collection of Result instances, then it will return an ArrayType which inner value
represent a Message which payload and attributes matches the types of the Result generics.
returnType - the source output typetypeLoader - a ClassTypeLoader used to create the MetadataTypeMetadataTypepublic static org.mule.metadata.api.model.MetadataType getMethodReturnAttributesType(Method method, org.mule.metadata.api.ClassTypeLoader typeLoader)
MetadataType representing the Result.getAttributes() that will be set after executing the given
method.
If the method returns a Result, then it returns the type of the Attributes generic. In any other case
(including raw uses of Result) it will return a VoidType
If the method returns a collection or a PagingProvider of Result, then this will return
VoidType since the messages in the main output already contain an attributes for each item.
method - the Method being introspectedtypeLoader - a ClassTypeLoader used to create the MetadataTypeMetadataTypeIllegalArgumentException - is method is nullpublic static List<org.mule.metadata.api.model.MetadataType> getGenerics(Type type, org.mule.metadata.api.ClassTypeLoader typeLoader)
public static boolean isLifecycle(Class<?> type)
type implements any of the lifecycle annotationstype - the class to evaluatepublic static org.mule.metadata.api.model.MetadataType[] getMethodArgumentTypes(Method method, org.mule.metadata.api.ClassTypeLoader typeLoader)
MetadataType representing each of the given Method's argument types.method - a not null MethodtypeLoader - a ClassTypeLoader to be used to create the returned MetadataTypesMetadataType matching the method's arguments. If the method doesn't take any, then the array will
be emptyIllegalArgumentException - is method is nullpublic static org.mule.metadata.api.model.MetadataType getFieldMetadataType(Field field, org.mule.metadata.api.ClassTypeLoader typeLoader)
MetadataType describing the given Field's typefield - a not null FieldtypeLoader - a ClassTypeLoader used to create the MetadataTypeMetadataType matching the field's typeIllegalArgumentException - if field is nullpublic static Optional<Field> getFieldByNameOrAlias(Class<?> clazz, String nameOrAlias)
public static Optional<Field> getField(Class<?> clazz, org.mule.runtime.api.meta.model.parameter.ParameterModel parameterModel)
public static Optional<Field> getField(Class<?> clazz, org.mule.runtime.api.meta.model.declaration.fluent.ParameterDeclaration parameterDeclaration)
public static Object getFieldValue(Object object, String fieldName) throws IllegalAccessException, NoSuchFieldException
object - The object where grab the field valuefieldName - The name of the field to obtain the valueIllegalAccessException - if is unavailable to access to the fieldNoSuchFieldException - if the field doesn't exist in the given object instancepublic static String getMemberName(org.mule.runtime.api.meta.model.EnrichableModel enrichableModel, String defaultName)
public static boolean hasDefaultConstructor(Class<?> clazz)
public static List<Class<?>> getInterfaceGenerics(Class<?> type, Class<?> implementedInterface)
public static List<Class<?>> findGenericsInSuperHierarchy(Class<?> type)
public static List<Type> getSuperClassGenerics(Class<?> type, Class<?> superClass)
public static void checkInstantiable(Class<?> declaringClass)
public static void checkInstantiable(Class<?> declaringClass, boolean requireDefaultConstructor)
public static boolean isInstantiable(org.mule.metadata.api.model.MetadataType type)
public static boolean isInstantiable(Class<?> declaringClass)
public static boolean isInstantiable(Class<?> declaringClass, boolean requireDefaultConstructor)
public static boolean assignableFromAny(Class<?> type, Collection<Class<?>> matchingTypes)
type is assignable from any of the matchingTypespublic static boolean isRequired(AccessibleObject object)
public static boolean isRequired(org.mule.runtime.api.meta.model.parameter.ParameterModel parameterModel,
boolean forceOptional)
public static boolean isVoid(Method method)
public static boolean isVoid(org.mule.runtime.api.meta.model.ComponentModel componentModel)
public static Collection<Method> getApiMethods(Class<?> declaringClass)
public static Collection<Method> getMethodsAnnotatedWith(Class<?> declaringClass, Class<? extends Annotation> annotationType)
declaringClass which are annotated with annotationType, including those
declared in super classes.declaringClass - the type to introspectannotationType - the annotation you're looking forCollection of Methodspublic static Collection<Method> getMethodsAnnotatedWith(Class<?> declaringClass, Class<? extends Annotation> annotationType, boolean superClasses)
declaringClass which are annotated with annotationTypedeclaringClass - the type to introspectannotationType - the annotation you're looking forsuperClasses - whether to consider supper classes or notCollection of Methodspublic static List<Field> getAnnotatedFields(Class<?> clazz, Class<? extends Annotation> annotationType)
public static List<Field> getFieldsOfType(Class<?> introspectedType, Class fieldType)
public static <T extends AnnotatedElement & Member> String getAlias(T element)
Alias name of the given element. If the element doesn't have an alias, then the default name is
returnT - the generic type of the elementelement - an annotated memberpublic static Collection<Field> getExposedFields(Class<?> extensionType)
public static org.mule.runtime.api.meta.ExpressionSupport getExpressionSupport(AnnotatedElement object)
public static org.mule.runtime.api.meta.ExpressionSupport getExpressionSupport(org.mule.runtime.extension.api.annotation.Expression expressionAnnotation)
public static String getSourceName(Class<? extends org.mule.runtime.extension.api.runtime.source.Source> sourceType)
public static <T extends Annotation> T getAnnotation(Class<?> annotatedClass, Class<T> annotationClass)
public static Set<Class<?>> getParameterClasses(org.mule.runtime.api.meta.model.ExtensionModel extensionModel, ClassLoader extensionClassLoader)
ParameterModels of the extensionModel and returns the classes that
are modeled by each parameter's Typed.getType().
This includes every single ParameterModel in the model, including configs, providers, operations, etc.
extensionModel - a ExtensionModelnull Setpublic static Set<Class<?>> collectRelativeClasses(org.mule.metadata.api.model.MetadataType type, ClassLoader extensionClassLoader)
MetadataType it adds all the Class that are related from that type. This includes generics of an
ArrayType, open restriction of an ObjectType as well as its fields.type - MetadataType to inspectextensionClassLoader - extension class loaderSet> with the classes reachable from the typepublic static boolean isMultiLevelMetadataKeyId(Set<Class<? extends Annotation>> annotations, org.mule.metadata.api.model.MetadataType parameterType)
Set of Annotation classes and a MetadataType that describes a component parameter, indicates if the
parameter is considered as a multilevel MetadataKeyIdannotations - of the parameterparameterType - of the parameterMetadataKeyIdpublic static boolean isParameterContainer(Set<Class<? extends Annotation>> annotations, org.mule.metadata.api.model.MetadataType parameterType)
Set of annotation classes and a MetadataType of a component parameter, indicates if the parameter is
a parameter container.
To be a parameter container means that the parameter is a ParameterGroup or a multilevel MetadataKeyId.
annotations - of the component parameterparameterType - of the component parameterpublic static Optional<AnnotatedElement> getAnnotatedElement(org.mule.runtime.api.meta.model.declaration.fluent.BaseDeclaration<?> declaration)
public static String getContainerName(AnnotatedElement container)
public static String getGroupModelContainerName(org.mule.runtime.api.meta.model.parameter.ParameterGroupModel groupModel)
public static String getImplementingName(org.mule.runtime.api.meta.model.declaration.fluent.ParameterDeclaration parameterDeclaration)
parameterDeclaration - parameter from which look for their original namepublic static String getImplementingName(org.mule.runtime.api.meta.model.parameter.ParameterModel parameterModel)
parameterModel - parameter from which look for their original namepublic static boolean isParameterResolver(org.mule.metadata.api.model.MetadataType metadataType)
public static boolean isTargetParameter(Set<org.mule.runtime.api.meta.model.ModelProperty> modelProperties)
public static boolean isLiteral(org.mule.metadata.api.model.MetadataType metadataType)
public static boolean isTypedValue(org.mule.metadata.api.model.MetadataType metadataType)
public static Optional<org.mule.runtime.api.meta.model.connection.ConnectionProviderModel> getConnectionProviderModel(Class<? extends org.mule.runtime.api.connection.ConnectionProvider> connectionProvider, List<org.mule.runtime.api.meta.model.connection.ConnectionProviderModel> allConnectionProviders)
ConnectionProviderModel for a given ConnectionProvider instance.connectionProvider - connection provider classallConnectionProviders - list of available ConnectionProviderModelOptional value of the ConnectionProviderModelpublic static void injectFields(org.mule.runtime.api.meta.model.EnrichableModel model,
Object target,
String configName,
String encoding)
configName into the field of the target annotated RefName (if it's present) and does the same for the
encoding and the field annotated with DefaultEncoding if the model contains the DeclaringMemberModelPropertymodel - enriched with InjectedFieldModelPropertytarget - object in which the fields are going to be setconfigName - to be injected into the String field annotated with RefNameencoding - to be injected into the String field annotated with DefaultEncodingpublic static void injectDefaultEncoding(org.mule.runtime.api.meta.model.EnrichableModel model,
Object target,
String encoding)
encoding value into the field of the target annotated DefaultEncoding if the model
contains the DeclaringMemberModelProperty property and the value is not null.model - enriched with DefaultEncodingModelPropertytarget - object in which the fields are going to be setencoding - to be injected into the String field annotated with DefaultEncodingpublic static void injectFields(Object target, String configName, String encoding)
configName into the field of the target annotated RefName (if it's present) and does the same for the
encoding and the field annotated with DefaultEncoding.target - object in which the fields are going to be setconfigName - to be injected into the String field annotated with RefNameencoding - to be injected into the String field annotated with DefaultEncoding{@link - IllegalModelDefinitionException} if there is more than one field annotated with DefaultEncodingpublic static void injectRefName(Object target, String configName)
target object for a field annotated with RefName. If found, it injects the
configName value into it.
The target object is expected to have only one field annotated with RefName and that field is
required to be a String.
target - object in which the value are going to be setconfigName - the value to be injectedpublic static void injectDefaultEncoding(Object target, String encoding)
encoding value into the field of the target annotated DefaultEncoding (if present)target - object in which the fields are going to be setencoding - to be injected into the String field annotated with DefaultEncoding{@link - IllegalModelDefinitionException} if there is more than one field annotated with DefaultEncodingpublic static Optional<FieldSetter> getDefaultEncodingFieldSetter(Object target)
target - object in which the fields are going to be set{@link - IllegalModelDefinitionException} if there is more than one field annotated with DefaultEncodingpublic static void injectComponentLocation(Object target, org.mule.runtime.api.component.location.ComponentLocation componentLocation)
target object for a field of type ComponentLocation. If found, it injects the
componentLocation value into it.
The target object is expected to have only one field of such type.
target - object in which the value are going to be setcomponentLocation - the value to be injectedpublic static org.mule.runtime.api.util.Pair<org.springframework.core.ResolvableType,org.springframework.core.ResolvableType> getPagingProviderTypes(org.springframework.core.ResolvableType pagingProvider)
PagingProvider type and returns their generics.pagingProvider - PagingProvider to introspectPagingProvider generics.Copyright © 2003–2017 MuleSoft, Inc.. All rights reserved.