top.lingkang.finalvalidated.handle.TakeValue Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of final-validator Show documentation
Show all versions of final-validator Show documentation
final-validator 是一个JavaBean元数据校验模型和方法验证,能够自定义注解来扩展校验范围,符合国内开发习惯的参数校验java库
The newest version!
package top.lingkang.finalvalidated.handle;
import java.lang.reflect.Field;
/**
* 反射取值
*
* @author lingkang
* @create by 2024/3/5 10:09
*/
class TakeValue {
private volatile Field field;
public TakeValue(Field field) {
this.field = field;
field.setAccessible(true);
}
public Object take(Object value) {
try {
return field.get(value);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
}
}