Java Reflection Method Setter Get getSetter(Class clazz, String property, Class type)

Here you can find the source of getSetter(Class clazz, String property, Class type)

Description

get Setter

License

Open Source License

Declaration

private static Method getSetter(Class<?> clazz, String property, Class<?> type) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.lang.reflect.Method;

public class Main {
    private static Method getSetter(Class<?> clazz, String property, Class<?> type) {
        String setterName = "set" + property.substring(0, 1).toUpperCase() + property.substring(1);
        try {//from ww  w  . jav a2 s.c o m
            Method method = clazz.getDeclaredMethod(setterName, type);
            return method;
        } catch (NoSuchMethodException e) {
            throw new IllegalArgumentException("no setter found for property '" + property + "'", e);
        }
    }
}

Related

  1. getSetter(A instance, String strAttributeName, Class clazz)
  2. getSetter(Class _class, String fieldName)
  3. getSetter(Class clazz, String name)
  4. getSetter(Class clazz, Field field)
  5. getSetter(Class clazz, Field field)
  6. getSetter(Class cls, final String fieldName)
  7. getSetter(final Class targetClass, final String propertyName)
  8. getSetter(final Class clazz, final String fieldName, final Class... fieldClass)
  9. getSetter(final Class clz, final String propertyName, final Class propertyClass)