|
Tuscany Core | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.tuscany.core.config.JavaIntrospectionHelper
public class JavaIntrospectionHelper
Implements various reflection-related operations
Method Summary | ||
---|---|---|
static boolean |
exactMethodMatch(Method method1,
Method method2)
Determines if two methods "match" - that is, they have the same method names and exact parameter types (one is not a supertype of the other) |
|
static Field |
findClosestMatchingField(String name,
Class type,
Set<Field> fields)
Finds the closest matching field with the given name, that is, a field of the exact specified type or, alternately, of a supertype. |
|
static Method |
findClosestMatchingMethod(String name,
Class[] types,
Set<Method> methods)
Finds the closest matching method with the given name, that is, a method taking the exact parameter types or, alternately, parameter supertypes. |
|
static Field |
findMultiplicityFieldByName(String name,
Set<Field> fields)
Searches a collection of fields for one that matches by name and has a multiplicity type. |
|
static Method |
findMultiplicityMethodByName(String name,
Set<Method> methods)
Searches a collection of method for one that matches by name and has single parameter of a multiplicity type. |
|
static Set<Field> |
getAllFields(Class pClass)
Returns a collection of public, private, protected, or default fields declared by a class or one of its supertypes |
|
static Set<Field> |
getAllPublicAndProtectedFields(Class clazz)
Returns a collection of public, and protected fields declared by a class or one of its supertypes |
|
static Set<Method> |
getAllUniqueMethods(Class clazz)
Returns a collection of public, private, protected, or default methods declared by a class or one of its supertypes. |
|
static String |
getBaseName(Class<?> implClass)
Returns the simple name of a class - i.e. |
|
static AccessibleObject |
getBeanProperty(Class clazz,
String propertName,
Class[] paramTypes)
Returns a field or method defined in the given class or its superclasses matching a literal name and parameter types This method can potentially be expensive as reflection information is not cached. |
|
static
|
getDefaultConstructor(Class<T> clazz)
|
|
static List<? extends Type> |
getGenerics(Type genericType)
Returns the generic types represented in the given type. |
|
static boolean |
isImmutable(Class clazz)
|
|
static Class |
loadClass(String pName)
Loads a class corresponding to the class name using the current context class loader. |
|
static String |
toGetter(String name)
Takes a property name and converts it to a getter method name according to JavaBean conventions. |
|
static String |
toPropertyName(String name)
Takes a setter or getter method name and converts it to a property name according to JavaBean conventions. |
|
static String |
toSetter(String name)
Takes a property name and converts it to a setter method name according to JavaBean conventions. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static Set<Field> getAllFields(Class pClass)
public static Set<Field> getAllPublicAndProtectedFields(Class clazz)
public static Set<Method> getAllUniqueMethods(Class clazz)
public static Field findClosestMatchingField(String name, Class type, Set<Field> fields)
name
- the name of the fieldtype
- the field typefields
- the collection of fields to search
public static Method findClosestMatchingMethod(String name, Class[] types, Set<Method> methods)
name
- the name of the methodtypes
- the method parameter typesmethods
- the collection of methods to search
public static Field findMultiplicityFieldByName(String name, Set<Field> fields)
public static Method findMultiplicityMethodByName(String name, Set<Method> methods)
public static AccessibleObject getBeanProperty(Class clazz, String propertName, Class[] paramTypes)
clazz
- the class to introspectpropertName
- the literal name of the property (i.e. JavaBean conventions are not applied)paramTypes
- the parameter types for a method or null for fields or methods with no parameters
public static boolean exactMethodMatch(Method method1, Method method2)
public static <T> Constructor<T> getDefaultConstructor(Class<T> clazz) throws NoSuchMethodException
NoSuchMethodException
public static Class loadClass(String pName) throws ClassNotFoundException
ClassNotFoundException
- if the class was not found on the classpathpublic static String getBaseName(Class<?> implClass)
implClass
- public static boolean isImmutable(Class clazz)
public static String toGetter(String name)
foo is returned as getFoo
public static String toPropertyName(String name)
setFoo(var)
is returned as property foo
public static String toSetter(String name)
foo is returned as setFoo(var)
public static List<? extends Type> getGenerics(Type genericType)
// to return the generic type of a field: JavaIntrospectionHelper.getGenerics(field.getGenericType());
// to return the generic types for the first parameter of a method: JavaIntrospectionHelper.getGenerics(m.getGenericParameterTypes()[0];);
|
Tuscany Core | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |