Search in sources :

Example 1 with MethodInvoker

use of org.apache.ibatis.reflection.invoker.MethodInvoker in project mybatis-3 by mybatis.

the class Reflector method addGetMethod.

private void addGetMethod(String name, Method method) {
    if (isValidPropertyName(name)) {
        getMethods.put(name, new MethodInvoker(method));
        Type returnType = TypeParameterResolver.resolveReturnType(method, type);
        getTypes.put(name, typeToClass(returnType));
    }
}
Also used : GenericArrayType(java.lang.reflect.GenericArrayType) ParameterizedType(java.lang.reflect.ParameterizedType) Type(java.lang.reflect.Type) MethodInvoker(org.apache.ibatis.reflection.invoker.MethodInvoker)

Example 2 with MethodInvoker

use of org.apache.ibatis.reflection.invoker.MethodInvoker in project mybatis-3 by mybatis.

the class MetaClass method getGenericGetterType.

private Type getGenericGetterType(String propertyName) {
    try {
        Invoker invoker = reflector.getGetInvoker(propertyName);
        if (invoker instanceof MethodInvoker) {
            Field _method = MethodInvoker.class.getDeclaredField("method");
            _method.setAccessible(true);
            Method method = (Method) _method.get(invoker);
            return TypeParameterResolver.resolveReturnType(method, reflector.getType());
        } else if (invoker instanceof GetFieldInvoker) {
            Field _field = GetFieldInvoker.class.getDeclaredField("field");
            _field.setAccessible(true);
            Field field = (Field) _field.get(invoker);
            return TypeParameterResolver.resolveFieldType(field, reflector.getType());
        }
    } catch (NoSuchFieldException e) {
    } catch (IllegalAccessException e) {
    }
    return null;
}
Also used : Field(java.lang.reflect.Field) GetFieldInvoker(org.apache.ibatis.reflection.invoker.GetFieldInvoker) Invoker(org.apache.ibatis.reflection.invoker.Invoker) GetFieldInvoker(org.apache.ibatis.reflection.invoker.GetFieldInvoker) MethodInvoker(org.apache.ibatis.reflection.invoker.MethodInvoker) Method(java.lang.reflect.Method) MethodInvoker(org.apache.ibatis.reflection.invoker.MethodInvoker)

Example 3 with MethodInvoker

use of org.apache.ibatis.reflection.invoker.MethodInvoker in project mybatis-3 by mybatis.

the class Reflector method addSetMethod.

private void addSetMethod(String name, Method method) {
    if (isValidPropertyName(name)) {
        setMethods.put(name, new MethodInvoker(method));
        Type[] paramTypes = TypeParameterResolver.resolveParamTypes(method, type);
        setTypes.put(name, typeToClass(paramTypes[0]));
    }
}
Also used : GenericArrayType(java.lang.reflect.GenericArrayType) ParameterizedType(java.lang.reflect.ParameterizedType) Type(java.lang.reflect.Type) MethodInvoker(org.apache.ibatis.reflection.invoker.MethodInvoker)

Aggregations

MethodInvoker (org.apache.ibatis.reflection.invoker.MethodInvoker)3 GenericArrayType (java.lang.reflect.GenericArrayType)2 ParameterizedType (java.lang.reflect.ParameterizedType)2 Type (java.lang.reflect.Type)2 Field (java.lang.reflect.Field)1 Method (java.lang.reflect.Method)1 GetFieldInvoker (org.apache.ibatis.reflection.invoker.GetFieldInvoker)1 Invoker (org.apache.ibatis.reflection.invoker.Invoker)1