mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-07 00:58:24 +08:00
fix: 修正 PropertyNamer#methodToProperty 方法。
This commit is contained in:
parent
79848b304b
commit
fa8c1ae5e4
@ -16,7 +16,10 @@
|
||||
package com.mybatisflex.core.util;
|
||||
|
||||
|
||||
import com.mybatisflex.core.exception.FlexExceptions;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Locale;
|
||||
import java.util.function.Function;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@ -25,6 +28,23 @@ public class StringUtil {
|
||||
private StringUtil() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.apache.ibatis.reflection.property.PropertyNamer#methodToProperty(String)
|
||||
*/
|
||||
public static String methodToProperty(String name) {
|
||||
if (name.startsWith("is")) {
|
||||
name = name.substring(2);
|
||||
} else if (name.startsWith("get") || name.startsWith("set")) {
|
||||
name = name.substring(3);
|
||||
} else {
|
||||
throw FlexExceptions.wrap("Error parsing property name '%s'. Didn't start with 'is', 'get' or 'set'.", name);
|
||||
}
|
||||
if (!name.isEmpty()) {
|
||||
name = name.substring(0, 1).toLowerCase(Locale.ENGLISH).concat(name.substring(1));
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 第一个字符转换为小写
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user