Example usage for org.apache.commons.lang3.reflect FieldUtils readStaticField

List of usage examples for org.apache.commons.lang3.reflect FieldUtils readStaticField

Introduction

In this page you can find the example usage for org.apache.commons.lang3.reflect FieldUtils readStaticField.

Prototype

public static Object readStaticField(final Field field) throws IllegalAccessException 

Source Link

Document

Reads an accessible static Field .

Usage

From source file:com.github.daddo.validation.validator.Util.java

public static Object accessStaticFieldByName(Class<?> clasz, String fieldName) {
    try {/*from  w  w w .j ava2 s.  co m*/
        Field field = FieldUtils.getField(clasz, fieldName);
        return FieldUtils.readStaticField(field);
    } catch (IllegalAccessException ex) {
        throw new StaticFieldAccessException("Unable to access field " + clasz.getName() + "#" + fieldName, ex);
    } catch (IllegalArgumentException ex) {
        throw new StaticFieldAccessException("Unable to access field " + clasz.getName() + "#" + fieldName, ex);
    }
}