@Test public void testGetPropertyName() { Assert.assertEquals("name", NamingUtil.getPropertyName("getName")); Assert.assertEquals("name", NamingUtil.getPropertyName("setName")); Assert.assertNull(NamingUtil.getPropertyName("garbage")); Assert.assertNull(NamingUtil.getPropertyName("")); Assert.assertNull(NamingUtil.getPropertyName("get")); Assert.assertNull(NamingUtil.getPropertyName("set")); Assert.assertEquals("sampleUnit",NamingUtil.getPropertyName("getsampleUnit")); Assert.assertEquals("sampleUnit",NamingUtil.getPropertyName("getSampleUnit")); }
public static String getPropertyName(String methodName) { if (StringUtil.isEmpty(methodName) || methodName.length()<=3) { return null; } if (methodName.startsWith("get") || methodName.startsWith("set")) { String prop = methodName.substring(4); char c = Character.toLowerCase(methodName.charAt(3)); return c+prop; } else { return null; } }
NamingUtil { public static String getPropertyName(String methodName) { if (StringUtil.isEmpty(methodName) || methodName.length()<=3) { return null; } if (methodName.startsWith("get") || methodName.startsWith("set")) { String prop = methodName.substring(4); char c = Character.toLowerCase(methodName.charAt(3)); return c+prop; } else { return null; } } }
NamingUtil { public static String getPropertyName(String methodName) { if (StringUtil.isEmpty(methodName) || methodName.length()<=3) { return null; } if (methodName.startsWith("get") || methodName.startsWith("set")) { String prop = methodName.substring(4); char c = Character.toLowerCase(methodName.charAt(3)); return c+prop; } else { return null; } } private  NamingUtil(); }
NamingUtil { public static String getPropertyName(String methodName) { if (StringUtil.isEmpty(methodName) || methodName.length()<=3) { return null; } if (methodName.startsWith("get") || methodName.startsWith("set")) { String prop = methodName.substring(4); char c = Character.toLowerCase(methodName.charAt(3)); return c+prop; } else { return null; } } private  NamingUtil(); static String toLabel(String name); static String toGetterName(String name); static String toSetterName(String name); static String toAttributeName(String name); static String toElementName(String name); static String toDisplayName(String name); static String toSQLName(String name); static String getPropertyName(String methodName); static String getSimpleName(String qualifiedName); static String getPackageName(String qualifiedName); }
NamingUtil { public static String getPropertyName(String methodName) { if (StringUtil.isEmpty(methodName) || methodName.length()<=3) { return null; } if (methodName.startsWith("get") || methodName.startsWith("set")) { String prop = methodName.substring(4); char c = Character.toLowerCase(methodName.charAt(3)); return c+prop; } else { return null; } } private  NamingUtil(); static String toLabel(String name); static String toGetterName(String name); static String toSetterName(String name); static String toAttributeName(String name); static String toElementName(String name); static String toDisplayName(String name); static String toSQLName(String name); static String getPropertyName(String methodName); static String getSimpleName(String qualifiedName); static String getPackageName(String qualifiedName);  }