Convert method to property name.
//package org.nestframework.utils;
import java.beans.BeanInfo;
import java.beans.IntrospectionException;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.Reader;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
/**
* Nest utility class.
*
* @author audin
*
*/
public class NestUtil {
/**
* Convert mathod to property name.
*
* @param m Method.
* @return
*/
public static String methodToPropertyName(Method m) {
//if (log.isDebugEnabled()) {
//log.debug("methodToPropertyName(Method) - start");
// }
String name = m.getName();
if ((name.startsWith("set") || name.startsWith("get"))
&& name.length() > 3) {
String ret = name.substring(3, 4).toLowerCase();
if (name.length() > 4)
ret += name.substring(4);
// if (log.isDebugEnabled()) {
// log.debug("methodToPropertyName(Method) - end");
// }
return ret;
} else {
// if (log.isDebugEnabled()) {
// log.debug("methodToPropertyName(Method) - end");
// }
return name;
}
}
}
Related examples in the same category