Code example for Field

Methods: getGenericType

package org.n3r.bytes.util; 
import java.lang.reflect.Field; 
import java.lang.reflect.ParameterizedType; 
public class Fields { 
    //Returns generic type of any field 
    public static Class getFieldGenericType(Field field) {
        if (ParameterizedType.class.isAssignableFrom(field.getGenericType().getClass())) {
            ParameterizedType genericType = (ParameterizedType) field.getGenericType();
            return (Class) genericType.getActualTypeArguments()[0];
        return Void.class;
    public static void setFieldValue(Field field, Object bean, Object value) {
        try { 
            field.set(bean, value);
        } catch (Throwable e) {
            throw Throws.propagate(e);
Stop searching for code, let great code find you!  Add Codota to your java IDE