@Test public void getting_member_name_returns_name_of_property_from_getter() throws NoSuchMethodException { Method property = TestClass.class.getMethod("getSymbol"); String memberName = PropertyUtil.getMemberNameFromMethod(property); assertEquals("Symbol", memberName); }
public static String getMemberNameFromMethod(Method method) { String name = method.getName(); if(name.startsWith("get") || name.startsWith("set")) { return name.substring(3); } if(name.startsWith("is") && Character.isUpperCase(name.charAt(2))) { return name.substring(2); } return name; }
PropertyUtil { public static String getMemberNameFromMethod(Method method) { String name = method.getName(); if(name.startsWith("get") || name.startsWith("set")) { return name.substring(3); } if(name.startsWith("is") && Character.isUpperCase(name.charAt(2))) { return name.substring(2); } return name; } }
PropertyUtil { public static String getMemberNameFromMethod(Method method) { String name = method.getName(); if(name.startsWith("get") || name.startsWith("set")) { return name.substring(3); } if(name.startsWith("is") && Character.isUpperCase(name.charAt(2))) { return name.substring(2); } return name; }  }
PropertyUtil { public static String getMemberNameFromMethod(Method method) { String name = method.getName(); if(name.startsWith("get") || name.startsWith("set")) { return name.substring(3); } if(name.startsWith("is") && Character.isUpperCase(name.charAt(2))) { return name.substring(2); } return name; }  static Boolean isMethodASetterProperty(Method method, Class clazz); static String getMemberNameFromMethod(Method method); }
PropertyUtil { public static String getMemberNameFromMethod(Method method) { String name = method.getName(); if(name.startsWith("get") || name.startsWith("set")) { return name.substring(3); } if(name.startsWith("is") && Character.isUpperCase(name.charAt(2))) { return name.substring(2); } return name; }  static Boolean isMethodASetterProperty(Method method, Class clazz); static String getMemberNameFromMethod(Method method);  }