Java Reflection Method Getter Get getGetter(Class realClass, String pAttributeName)

Here you can find the source of getGetter(Class realClass, String pAttributeName)

Description

get Getter

License

Apache License

Declaration

public static <E> Method getGetter(Class<E> realClass, String pAttributeName) throws Exception 

Method Source Code

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

import java.lang.reflect.Method;

public class Main {
    public static <E> Method getGetter(Class<E> realClass, String pAttributeName) throws Exception {
        if (realClass == null || pAttributeName == null || pAttributeName.trim().equals("")) {
            throw new Exception("Error ::: realClass is null or pAttributeName is null or empty string ");
        }//from w w  w .j ava  2 s  .co m

        Method getter = realClass.getDeclaredMethod(
                "get" + pAttributeName.substring(0, 1).toUpperCase() + pAttributeName.substring(1));
        return getter;
    }
}

Related

  1. getGetter(Class c, Field field)
  2. getGetter(Class clazz, String name)
  3. getGetter(Class clazz, Field field)
  4. getGetter(Class clazz, Field field)
  5. getGetter(Class cls, String name, Class type)
  6. getGetter(final Class clazz, final String propertyName)
  7. getGetter(final Class clazz, final String fieldName)
  8. getGetter(final Class clz, final String propertyName)
  9. getGetter(final Object o, final String fieldName)