Java Reflection Method Setter Get getSetterName(Method m)

Here you can find the source of getSetterName(Method m)

Description

Get setter name.

License

Apache License

Parameter

Parameter Description
m Method object.

Return

Property name of this setter.

Declaration

private static String getSetterName(Method m) 

Method Source Code

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

import java.lang.reflect.Method;

public class Main {
    /**/*from  w  w w.  ja v a 2s .  c om*/
     * Get setter name. "setName" -> "name"
     * 
     * @param m Method object.
     * @return Property name of this setter.
     */
    private static String getSetterName(Method m) {
        String name = m.getName();
        if (name.startsWith("set") && (name.length() >= 4) && m.getReturnType().equals(void.class)
                && (m.getParameterTypes().length == 1)) {
            return Character.toLowerCase(name.charAt(3)) + name.substring(4);
        }
        return null;
    }
}

Related

  1. getSetterMethods(Class pojoClass)
  2. getSetterMethods(final Class clazz)
  3. getSetterName(Field field)
  4. getSetterName(final Field field)
  5. getSetterName(Method m)
  6. getSetterName(Method method)
  7. getSetterName(String name)
  8. getSetterOrGetter(Class clazz, String name, boolean isSetter)
  9. getSetters(Class clazz)