Commit 3bb71060 authored by liaozan's avatar liaozan 🏀

Rename bizField getter、setter variable name

parent 5473de9f
......@@ -2,7 +2,7 @@ package com.schbrain.framework.autoconfigure.mybatis.biz;
import com.schbrain.common.exception.BaseException;
import com.schbrain.framework.autoconfigure.mybatis.annotation.BizId;
import lombok.Data;
import lombok.Getter;
import java.lang.invoke.MethodHandle;
import java.lang.reflect.Field;
......@@ -13,7 +13,7 @@ import static java.lang.invoke.MethodHandles.*;
* @author liaozan
* @since 2023-03-23
*/
@Data
@Getter
public class BizIdColumnField {
private final BizId annotation;
......@@ -22,9 +22,9 @@ public class BizIdColumnField {
private final Class<?> fieldType;
private final MethodHandle bizIdFieldGetterMethodHandle;
private final MethodHandle getter;
private final MethodHandle bizIdFieldSetterMethodHandle;
private final MethodHandle setter;
public BizIdColumnField(Class<?> entityClass, Field bizIdField) {
this.annotation = bizIdField.getAnnotation(BizId.class);
......@@ -32,8 +32,8 @@ public class BizIdColumnField {
this.fieldType = bizIdField.getType();
try {
Lookup lookup = privateLookupIn(entityClass, lookup());
this.bizIdFieldGetterMethodHandle = lookup.findGetter(entityClass, bizIdField.getName(), fieldType);
this.bizIdFieldSetterMethodHandle = lookup.findSetter(entityClass, bizIdField.getName(), fieldType);
this.getter = lookup.findGetter(entityClass, bizIdField.getName(), fieldType);
this.setter = lookup.findSetter(entityClass, bizIdField.getName(), fieldType);
} catch (NoSuchFieldException | IllegalAccessException e) {
throw new BaseException(e.getMessage(), e);
}
......@@ -42,7 +42,7 @@ public class BizIdColumnField {
@SuppressWarnings("unchecked")
public <V, T> V getValue(T entity) {
try {
return (V) bizIdFieldGetterMethodHandle.invoke(entity);
return (V) getter.invoke(entity);
} catch (Throwable e) {
throw new BaseException(e.getMessage(), e);
}
......@@ -50,14 +50,10 @@ public class BizIdColumnField {
public <V, T> void setValue(T entity, V value) {
try {
bizIdFieldSetterMethodHandle.invoke(entity, value);
setter.invoke(entity, value);
} catch (Throwable e) {
throw new BaseException(e.getMessage(), e);
}
}
public Class<?> getFieldType() {
return fieldType;
}
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment