anima
anima copied to clipboard
关于methodToFieldName方法,methodName.replace("get", "")问题
如果属性为TargetId, 使用methodToFieldName方法问题
public static String methodToFieldName(String methodName) {
return capitalize(methodName.replace("get", ""));
}
String result = "getTargetId".replace("get", "");
// 输出值为TarId,正确应该是TargetId
可以使用replaceFirst
String result = "getTargetId".replaceFirst("get", "");
// 输出TargetId