Java Reflection Field Value Set setFieldValue(Object pojo, Field field, Object value)

Here you can find the source of setFieldValue(Object pojo, Field field, Object value)

Description

set Field Value

License

Open Source License

Parameter

Parameter Description
pojo a parameter
field a parameter
value a parameter

Exception

Parameter Description
SecurityException an exception
NoSuchFieldException an exception
IllegalArgumentException an exception
IllegalAccessException an exception

Declaration

public static void setFieldValue(Object pojo, Field field, Object value)
        throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.lang.reflect.Field;

public class Main {
    /**//  ww w  .  j  a va2 s .  co m
     * 
     * @param pojo
     * @param field
     * @param value
     * @throws SecurityException
     * @throws NoSuchFieldException
     * @throws IllegalArgumentException
     * @throws IllegalAccessException
     */
    public static void setFieldValue(Object pojo, Field field, Object value)
            throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
        field.setAccessible(true);
        field.set(pojo, value);
    }
}

Related

  1. setFieldValue(Object object, String fieldName, Object value)
  2. setFieldValue(Object object, String fieldName, Object value)
  3. setFieldValue(Object object, String name, Object value)
  4. setFieldValue(Object object, String name, Object value)
  5. setFieldValue(Object objectInstance, String fieldName, Object valueToSet)
  6. setFieldValue(Object receiver, String fieldName, Object value)
  7. setFieldValue(Object target, Class targetClass, String fieldName, Object value)
  8. setFieldValue(Object target, Field field, Object newValue)
  9. setFieldValue(Object target, Field field, Object value)