Java Reflection Method Getter Get getGetter(Class clazz, Field field)

Here you can find the source of getGetter(Class clazz, Field field)

Description

get Getter

License

Apache License

Declaration

public static Method getGetter(Class<?> clazz, Field field) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.lang.reflect.Field;
import java.lang.reflect.Method;

public class Main {
    public static Method getGetter(Class<?> clazz, Field field) {
        String filedName = field.getName();
        String firstLetter = filedName.substring(0, 1).toUpperCase();
        String getMethodName = "get" + firstLetter + filedName.substring(1);
        Method getMethod = null;/*  w w w  . j a v  a 2s  . co  m*/
        try {
            getMethod = clazz.getDeclaredMethod(getMethodName);
        } catch (Exception e) {
        }
        return getMethod;
    }
}

Related

  1. getGetter(A instance, String strAttributeName, Class clazz)
  2. getGetter(Class _class, String fieldName)
  3. getGetter(Class c, Field field)
  4. getGetter(Class clazz, String name)
  5. getGetter(Class clazz, Field field)
  6. getGetter(Class cls, String name, Class type)
  7. getGetter(Class realClass, String pAttributeName)
  8. getGetter(final Class clazz, final String propertyName)
  9. getGetter(final Class clazz, final String fieldName)