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 |
getComponentDeclarationTypeName(Object component) |
static String |
getComponentModelTypeName(Object component) |
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<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 |
static String |
getModelName(Object model) |
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 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 |
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 |
isRequired(AccessibleObject object) |
static boolean |
isRequired(org.mule.runtime.api.meta.model.parameter.ParameterModel parameterModel,
boolean forceOptional) |
static boolean |
isVoid(org.mule.runtime.api.meta.model.ComponentModel componentModel) |
static boolean |
isVoid(Method method) |
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.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 Output generic. If the Result type is being used in its raw
form, then an AnyType will be returned.method - the Method being introspectedtypeLoader - a ClassTypeLoader used to create the MetadataTypeMetadataTypeIllegalArgumentException - is method is nullpublic 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
method - the Method being introspectedtypeLoader - a ClassTypeLoader used to create the MetadataTypeMetadataTypeIllegalArgumentException - is method is nullpublic 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(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 annotationTypedeclaringClass - the type to introspectannotationType - the annotation you're looking forCollection 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, key and value of an DictionaryType and classes from the fields of ObjectType.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 String getComponentDeclarationTypeName(Object component)
public static Optional<AnnotatedElement> getAnnotatedElement(org.mule.runtime.api.meta.model.declaration.fluent.BaseDeclaration<?> declaration)
Copyright © 2003–2016 MuleSoft, Inc.. All rights reserved.