All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.es.plus.adapter.util.FieldUtils Maven / Gradle / Ivy

There is a newer version: 0.3.941
Show newest version
package com.es.plus.adapter.util;

import java.lang.reflect.Field;

public class FieldUtils {

    public static String getStrFieldValue(Object bean, String... field) {
        for (int i = 0; i < field.length; i++) {
            if (bean != null) {
                bean = getFieldValue(bean, field[i]);
            }
        }
        return (String) bean;
    }

    public static Object getFieldValue(Object bean, String field) {
        Class aClass = bean.getClass();
        Field declaredField = null;
        try {
            declaredField = aClass.getDeclaredField(field);
            declaredField.setAccessible(true);
            return declaredField.get(bean);
        } catch (Exception e) {
            return null;
        }
    }


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy