fix: EnumValue枚举方法级别逻辑判断优化

This commit is contained in:
hy 2024-01-18 23:15:59 +08:00
parent 64a625d098
commit 646caa4c8f

View File

@ -74,6 +74,10 @@ public class EnumWrapper<E extends Enum<E>> {
if (!hasEnumValueAnnotation) {
Method enumValueMethod = ClassUtil.getFirstMethod(enumClass, method -> method.getAnnotation(EnumValue.class) != null);
if (enumValueMethod != null) {
String methodName = enumValueMethod.getName();
if (!(methodName.startsWith("get") && methodName.length() > 3)) {
throw new IllegalStateException("Can not find get method \"" + methodName + "()\" in enum: " + enumClass.getName());
}
this.getterMethod = enumValueMethod;
}
}