Java Utililty Methods Reflection Method Getter Get

List of utility methods to do Reflection Method Getter Get

Description

The list of methods to do Reflection Method Getter Get are organized into topic(s).

Method

MethodgetGetter(final Class clz, final String propertyName)
get Getter
final Class<?> getterArgs[] = new Class<?>[0];
final String getterName = "get" + propertyName.substring(0, 1).toUpperCase() + propertyName.substring(1);
return clz.getMethod(getterName, getterArgs);
MethodgetGetter(final Object o, final String fieldName)
Returns the method of a given object which is the getter-method of a given field whose name is expected to be like getFieldname.
return getMethodWithPrefix(o, fieldName, "get").orElse(null);
MethodgetGetter(Object bean, String property)
get Getter
Map<String, Method> cache = GETTER_CACHE.get(bean.getClass());
if (cache == null) {
    cache = new ConcurrentHashMap<String, Method>();
    for (Method method : bean.getClass().getMethods()) {
        if (Modifier.isPublic(method.getModifiers()) && !Modifier.isStatic(method.getModifiers())
                && !void.class.equals(method.getReturnType()) && method.getParameterTypes().length == 0) {
            String name = method.getName();
            if (name.length() > 3 && name.startsWith("get")) {
...
MethodgetGetter(Object instance, String methodName)
get Getter
bld.setLength(0);
String key = bld.append(instance.getClass().getName()).append(".").append(methodName).toString();
Method getter = getters.get(key);
if (getter == null) {
    Method[] ms = instance.getClass().getMethods();
    for (Method m : ms) {
        if (m.getName().equals(methodName) && m.getParameterTypes().length == 0
                && m.getReturnType() != null) {
...
MethodgetGetter(Object o, String name)
get Getter
String capitalizedName = capitalize(name);
Method method = getMethod(o, GET_ROOT + capitalizedName);
return (method != null ? method : getMethod(o, IS_ROOT + capitalizedName));
MethodgetGetter(Object object, String name)
get getter by name
String getterName = "get" + capitaliseName(name);
return getMethod(object, getterName);
MethodgetGetter(String key, Class clazz)
get Getter
if (!key.startsWith("get")) {
    key = "get" + getDefaultProperty(key);
try {
    return clazz.getMethod(key, new Class[0]);
} catch (Exception e) {
    return null;
StringgetGetter(String name, Type type)
get Getter
if (name.startsWith("_"))
    name = name.substring(1);
String prefix;
if (type != null && boolean.class.equals(type)) {
    prefix = "is";
} else {
    prefix = "get";
return prefix + name.substring(0, 1).toUpperCase() + name.substring(1);
MethodgetGetter(String propertyName, Class clazz)
get Getter
String[] names = { String.format("get%s", capitalize(propertyName)), 
        String.format("is%s", capitalize(propertyName)) 
};
for (Method m : clazz.getMethods()) {
    for (String name : names) {
        if (m.getName().equals(name)) {
            return m;
return null;
ClassgetGetterAttributeType(Method m)
get Getter Attribute Type
return m.getReturnType();