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 String |
getContainerName(AnnotatedElement container) |
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 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 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.springframework.core.ResolvableType |
getMethodType(Method method) |
static Collection<Method> |
getOperationMethods(Class<?> declaringClass) |
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 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 |
isLiteral(Set<org.mule.runtime.api.meta.model.ModelProperty> modelProperties) |
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 |
isParameterResolver(Set<org.mule.runtime.api.meta.model.ModelProperty> modelProperties) |
static boolean |
isRequired(AccessibleObject object) |
static boolean |
isRequired(org.mule.runtime.api.meta.model.parameter.ParameterModel parameterModel,
boolean forceOptional) |
static boolean |
isTypedValue(org.mule.metadata.api.model.MetadataType metadataType) |
static boolean |
isTypedValue(Set<org.mule.runtime.api.meta.model.ModelProperty> modelProperties) |
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 |
static org.springframework.core.ResolvableType |
unwrapGenericFromClass(Class<?> clazz,
org.springframework.core.ResolvableType type,
int genericIndex) |
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 org.springframework.core.ResolvableType getMethodType(Method method)
public static org.springframework.core.ResolvableType unwrapGenericFromClass(Class<?> clazz, org.springframework.core.ResolvableType type, int genericIndex)
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> getOperationMethods(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 <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 boolean isParameterResolver(Set<org.mule.runtime.api.meta.model.ModelProperty> modelProperties)
public static boolean isParameterResolver(org.mule.metadata.api.model.MetadataType metadataType)
public static boolean isLiteral(Set<org.mule.runtime.api.meta.model.ModelProperty> modelProperties)
public static boolean isLiteral(org.mule.metadata.api.model.MetadataType metadataType)
public static boolean isTypedValue(Set<org.mule.runtime.api.meta.model.ModelProperty> modelProperties)
public static boolean isTypedValue(org.mule.metadata.api.model.MetadataType metadataType)
Copyright © 2003–2017 MuleSoft, Inc.. All rights reserved.