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

org.jolokia.test.util.ReflectionTestUtil Maven / Gradle / Ivy

There is a newer version: 2.1.1
Show newest version
package org.jolokia.test.util;

import java.lang.reflect.Field;

/**
 * @author roland
 * @since 25.02.14
 */
public class ReflectionTestUtil {

    private ReflectionTestUtil() {}

    public static void setField(Object pObject,String pField, Object pValue) throws NoSuchFieldException, IllegalAccessException {
        Class cl = pObject.getClass();
        Field field = cl.getDeclaredField(pField);
        field.setAccessible(true);
        field.set(pObject,pValue);
    }

    public static Object getField(Object pObject,String pField) throws NoSuchFieldException, IllegalAccessException {
        Class cl = pObject.getClass();
        Field field = cl.getDeclaredField(pField);
        field.setAccessible(true);
        return field.get(pObject);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy