Java examples for Reflection:Setter
parse Setter
//package com.java2s; import java.lang.reflect.Method; public class Main { private static final String SET_PREFIX = "set"; public static Method parseSetter(Object bean, String propertyName, Class<?> propertyClass) throws SecurityException, NoSuchMethodException { return bean.getClass().getMethod( getSetMethodName(propertyName, propertyClass)); }// w ww. jav a 2 s.com public static String getSetMethodName(String propertyName, Class<?> propertyClass) { return SET_PREFIX + capitalizeMethodName(propertyName); } private static String capitalizeMethodName(String propertyName) { StringBuilder sb = new StringBuilder(); sb.append(Character.toUpperCase(propertyName.charAt(0))); sb.append(propertyName.substring(1)); return sb.toString(); } }