import com.thoughtworks.paranamer.*; public class MyClass { private String myProperty; public String getMyProperty() { return myProperty; } public void setMyProperty(String myProperty) { this.myProperty = myProperty; } public static void main(String[] args) { ParaNamer paranamer = new BytecodeReadingParanamer(); Class<?> clazz = MyClass.class; String[] propertyNames = paranamer.lookupParameterNames(clazz.getDeclaredFields()[0]); System.out.println("Property name: " + propertyNames[0]); Method method = clazz.getDeclaredMethods()[0]; String[] methodNames = paranamer.lookupParameterNames(method); System.out.println("Method name: " + methodNames[0]); } }


上一篇:
下一篇:
切换中文