feat: optimize FieldWrapper.java

This commit is contained in:
michael 2024-01-21 12:58:51 +08:00
parent f8f9583bfc
commit ab7e705b45

View File

@ -53,7 +53,7 @@ public class FieldWrapper {
if (fieldWrapper == null) {
Field findField = ClassUtil.getFirstField(clazz, field -> field.getName().equals(fieldName));
if (findField == null) {
throw new IllegalStateException("Can not find field \"" + fieldName + "\" in class: " + clazz);
throw new IllegalStateException("Can not find field \"" + fieldName + "\" in class: " + clazz.getName());
}
String setterName = "set" + StringUtil.firstCharToUpperCase(fieldName);
@ -117,7 +117,7 @@ public class FieldWrapper {
public void set(Object value, Object to) {
try {
if (setterMethod == null) {
throw new IllegalStateException("Can not find method \"set" + StringUtil.firstCharToUpperCase(field.getName()) + "\" in class: " + to.getClass());
throw new IllegalStateException("Can not find method \"set" + StringUtil.firstCharToUpperCase(field.getName()) + "\" in class: " + to.getClass().getName());
}
setterMethod.invoke(to, value);
} catch (Exception e) {
@ -128,7 +128,8 @@ public class FieldWrapper {
public Object get(Object target) {
try {
if (getterMethod == null) {
throw new IllegalStateException("Can not find method \"get" + StringUtil.firstCharToUpperCase(field.getName()) + ", is" + StringUtil.firstCharToUpperCase(field.getName()) + "\" in class: " + target.getClass());
throw new IllegalStateException("Can not find method \"get" + StringUtil.firstCharToUpperCase(field.getName()) + ", is"
+ StringUtil.firstCharToUpperCase(field.getName()) + "\" in class: " + target.getClass().getName());
}
return getterMethod.invoke(target);
} catch (Exception e) {