Search in sources :

Example 6 with MethodAccessor

use of sun.reflect.MethodAccessor in project sql2o by aaberg.

the class MethodAccessorsGenerator method newGetter.

public Getter newGetter(final Method method) {
    final Class type = method.getReturnType();
    final MethodAccessor methodAccessor = newMethodAccessor(method);
    return new Getter() {

        public Object getProperty(Object obj) {
            try {
                return methodAccessor.invoke(obj, null);
            } catch (InvocationTargetException e) {
                throw new Sql2oException("error while calling getter method with name " + method.getName() + " on class " + obj.getClass().toString(), e);
            }
        }

        public Class getType() {
            return type;
        }
    };
}
Also used : Sql2oException(org.sql2o.Sql2oException) MethodAccessor(sun.reflect.MethodAccessor) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

MethodAccessor (sun.reflect.MethodAccessor)6 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 Sql2oException (org.sql2o.Sql2oException)2 CallerSensitive (sun.reflect.CallerSensitive)2