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

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

Introduction

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

Prototype

public static Object readStaticField(Field field) throws IllegalAccessException 

Source Link

Document

Read an accessible static Field.

Usage

From source file:org.apache.hadoop.hive.ql.stats.TestStatsUtils.java

@Test
public void testPrimitiveSizeEstimations() throws Exception {
    HiveConf conf = new HiveConf();
    Set<String> exclusions = Sets.newHashSet();
    exclusions.add(serdeConstants.VOID_TYPE_NAME);
    exclusions.add(serdeConstants.LIST_TYPE_NAME);
    exclusions.add(serdeConstants.MAP_TYPE_NAME);
    exclusions.add(serdeConstants.STRUCT_TYPE_NAME);
    exclusions.add(serdeConstants.UNION_TYPE_NAME);
    Field[] serdeFields = serdeConstants.class.getFields();
    for (Field field : serdeFields) {
        if (!Modifier.isStatic(field.getModifiers())) {
            continue;
        }/*from w  w  w  . j  a  v  a2  s .  com*/
        if (!field.getName().endsWith("_TYPE_NAME")) {
            continue;
        }
        String typeName = (String) FieldUtils.readStaticField(field);
        if (exclusions.contains(typeName)) {
            continue;
        }
        long siz = StatsUtils.getSizeOfPrimitiveTypeArraysFromType(typeName, 3, conf);
        assertNotEquals(field.toString(), 0, siz);
    }
}