Java Utililty Methods Reflection Method Setter Get

List of utility methods to do Reflection Method Setter Get

Description

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

Method

MethodgetSetterMethodByFieldName(String fieldName, Field field)
get Setter Method By Field Name
StringBuilder sb = new StringBuilder(fieldName.length() + 3);
sb.append("set");
sb.append(fieldName);
sb.setCharAt(3, Character.toUpperCase(sb.charAt(3)));
try {
    return field.getDeclaringClass().getDeclaredMethod(sb.toString(), field.getType());
} catch (NoSuchMethodException e) {
    return null;
...
MethodgetSetterMethodByProperty(String propertyName, Class beanClass, Class setterParamType)
get Setter Method By Property
return getSetterMethod(toSetterName(propertyName), beanClass, setterParamType);
MethodgetSetterMethodForClass(Class cls, String beanName, Class type)
Obtain a (Java bean) setter method from a class or superclasses using reflection.
return findDeclaredMethodInHeirarchy(cls, getJavaBeanSetterName(beanName), type);
MethodgetSetterMethodFromGetter(final Method getter)
Return a setter Method for a given getter Method .
if (!isGetter(getter)) {
    throw new IllegalArgumentException("Method is not a getter method!");
String[] prefixes = { "get", "is" };
String setterName;
for (String prefix : prefixes) {
    if (getter.getName().startsWith(prefix)) {
        String name = getter.getName().substring(prefix.length());
...
Method[]getSetterMethods(Class clazz)
get Setter Methods
if (clazz == null) {
    return new Method[] {};
Method[] methods = clazz.getMethods();
List<Method> mlist = new ArrayList<Method>();
for (int i = 0; i < methods.length; i++) {
    Method method = methods[i];
    String methodName = method.getName();
...
ListgetSetterMethods(Class clazz)
get Setter Methods
Method[] methods = clazz.getMethods();
ArrayList<Method> setterMethods = new ArrayList<Method>(methods.length);
for (Method method : methods) {
    if (!Modifier.isPublic(method.getModifiers()) || (method.getParameterTypes().length != 1)
            || !method.getName().startsWith("set")) {
        continue;
    setterMethods.add(method);
...
ListgetSetterMethods(Class clazz)
get Setter Methods
List<Method> props = new ArrayList<Method>();
for (Method method : clazz.getMethods()) {
    String methodName = method.getName();
    if (SETTER_METHOD_NAME_PATTERN.matcher(methodName).find() && method.getParameterTypes().length == 1) {
        props.add(method);
return props;
...
ListgetSetterMethods(Class objectType)
get Setter Methods
List<Method> result = new ArrayList<Method>();
Method[] methods = objectType.getMethods();
for (Method method : methods) {
    if (isValidSetterMethod(method)) {
        result.add(method);
return result;
...
MapgetSetterMethods(Class pojoClass)
Gets the setters of a pojo as a map of String as key and Method as value.
HashMap<String, Method> methods = new HashMap<String, Method>();
fillSetterMethods(pojoClass, methods);
return methods;
ListgetSetterMethods(final Class clazz)
get Setter Methods
final List<Method> result = new ArrayList<Method>();
for (Method m : clazz.getMethods()) {
    if (m.getName().startsWith("set")) {
        if (m.getParameterTypes().length == 1) {
            result.add(m);
return result;