Skip to content

关于methodToFieldName方法,methodName.replace("get", "")问题 #58

@cotide

Description

@cotide

如果属性为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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions