Search in sources :

Example 1 with FieldAndMethodCallBack

use of org.simpleflatmapper.reflect.meta.FieldAndMethodCallBack in project SimpleFlatMapper by arnaudroger.

the class ParamNameDeductor method listAccessors.

private List<Accessor<T>> listAccessors() {
    final List<Accessor<T>> list = new ArrayList<Accessor<T>>();
    ClassVisitor.visit(target, new FieldAndMethodCallBack() {

        ObjectGetterFactory objectGetterFactory = new ObjectGetterFactory(null);

        @Override
        public void method(Method method) {
            if (GetterHelper.isGetter(method)) {
                Getter<T, Object> methodGetter = objectGetterFactory.getMethodGetter(method);
                list.add(new Accessor<T>(GetterHelper.getPropertyNameFromMethodName(method.getName()), methodGetter));
            }
        }

        @Override
        public void field(Field field) {
            Getter<T, Object> fieldGetter = objectGetterFactory.getFieldGetter(field);
            list.add(new Accessor<T>(field.getName(), fieldGetter));
        }
    });
    return list;
}
Also used : FieldAndMethodCallBack(org.simpleflatmapper.reflect.meta.FieldAndMethodCallBack) Field(java.lang.reflect.Field) ConstantGetter(org.simpleflatmapper.reflect.getter.ConstantGetter) Getter(org.simpleflatmapper.reflect.Getter) ObjectGetterFactory(org.simpleflatmapper.reflect.ObjectGetterFactory) ArrayList(java.util.ArrayList) Method(java.lang.reflect.Method)

Aggregations

Field (java.lang.reflect.Field)1 Method (java.lang.reflect.Method)1 ArrayList (java.util.ArrayList)1 Getter (org.simpleflatmapper.reflect.Getter)1 ObjectGetterFactory (org.simpleflatmapper.reflect.ObjectGetterFactory)1 ConstantGetter (org.simpleflatmapper.reflect.getter.ConstantGetter)1 FieldAndMethodCallBack (org.simpleflatmapper.reflect.meta.FieldAndMethodCallBack)1