Java Reflection Method Setter Get getSetterForGetter(Method[] methods, Method getter)

Here you can find the source of getSetterForGetter(Method[] methods, Method getter)

Description

get Setter For Getter

License

Open Source License

Declaration

public static Method getSetterForGetter(Method[] methods, Method getter) 

Method Source Code

//package com.java2s;
/*//w  ww. j a v a2 s  . co  m
 *   $Id$
 *
 *   Copyright 2006 University of Dundee. All rights reserved.
 *   Use is subject to license terms supplied in LICENSE.txt
 */

import java.lang.reflect.Method;

public class Main {
    public static Method getSetterForGetter(Method[] methods, Method getter) {
        for (int i = 0; i < methods.length; i++) {
            Method method = methods[i];
            if (method.getName().startsWith("set")) {
                if (method.getName().substring(1).equals(getter.getName().substring(1))) {
                    return method;
                }
            }
        }
        return null;
    }
}

Related

  1. getSetter(String property, Object o)
  2. getSetter(String propertyName, Class clazz, Class arg)
  3. getSetter(String s)
  4. getSetterAttributeType(Method m)
  5. getSetterFieldName(Method method)
  6. getSetterFromCache(Class clazz)
  7. getSetterMap(Class cls)
  8. getSetterMethod(Class beanClass, String fieldName, List supportedTypes)
  9. getSetterMethod(Class c, String methodName)