package com.nantian.cloud.dbcapp.unit;

import java.lang.reflect.Field;

public class ObjectFieldUtil {

    // 根据属性名获取属性值
    public static Float getFieldFloatValueByFieldName(String fieldName, Object object) {
        try {
            Field field = object.getClass().getDeclaredField(fieldName);
            //设置对象的访问权限，保证对private的属性的访问
            field.setAccessible(true);
            return (Float)field.get(object);
        } catch (Exception e) {
            return null;
        }
    }

}
