src/main/java/com/rockagen/commons/util/ReflexUtil.java
public static void setFieldValue(final Object object, String fieldName,
			final Object value, boolean recursively) {

		if (object == null)
			return;

		Field field = ClassUtil.getDeclaredField(object.getClass(), fieldName,
				recursively);

		if (field == null) {
			log.debug("Could not find field [ {} ] on target [ {} ]",
					fieldName, object.getClass().getSimpleName());
			return;
		}

		String methodName = "set" + CommUtil.capitalize(fieldName);

		Method method = ClassUtil.getDeclaredMethod(object.getClass(),
				recursively, methodName,
				value == null ? Object.class : value.getClass());
		if (method != null) {
			try {
				makeAccessible(method);
				method.invoke(object, value);
				return;
			} catch (InvocationTargetException e) {
				log.debug("Could not find method [ {} ] on target [ {} ]",
						methodName, object.getClass().getSimpleName());
			} catch (NullPointerException e) {
				log.debug("{} field: [ {} ] is null", object.getClass()
						.getSimpleName(), fieldName);
			}catch (IllegalAccessException e) {
				// Will not happen
			}

		}

		makeAccessible(field);

		try {
			field.set(object, value);
		}catch (NullPointerException e) {
			log.debug("{} field: [ {} ] is null", object.getClass()
					.getSimpleName(), fieldName);
		} catch (IllegalAccessException e) {
			// Will not happen
		}
	}
public static void setFieldValue(final Object object, String fieldName,
			final Object value, boolean recursively) {

		if (object == null)
			return;

		Field field = ClassUtil.getDeclaredField(object.getClass(), fieldName,
				recursively);

		if (field == null) {
			log.debug("Could not find field [ {} ] on target [ {} ]",
					fieldName, object.getClass().getSimpleName());
			return;
		}

		String methodName = "set" + CommUtil.capitalize(fieldName);

		Method method = ClassUtil.getDeclaredMethod(object.getClass(),
				recursively, methodName,
				value == null ? Object.class : value.getClass());
		if (method != null) {
			try {
				makeAccessible(method);
				method.invoke(object, value);
				return;
			} catch (InvocationTargetException e) {
				log.debug("Could not find method [ {} ] on target [ {} ]",
						methodName, object.getClass().getSimpleName());
			} catch (NullPointerException e) {
				log.debug("{} field: [ {} ] is null", object.getClass()
						.getSimpleName(), fieldName);
			}catch (IllegalAccessException e) {
				// Will not happen
			}

		}

		makeAccessible(field);

		try {
			field.set(object, value);
		}catch (NullPointerException e) {
			log.debug("{} field: [ {} ] is null", object.getClass()
					.getSimpleName(), fieldName);
		} catch (IllegalAccessException e) {
			// Will not happen
		}
	}
public static void setFieldValue ( final Object object , String fieldName , final Object value , boolean recursively ) { if ( object == null ) return ; Field field = ClassUtil . getDeclaredField ( object . getClass ( ) , fieldName , recursively ) ; if ( field == null ) { log . debug ( "Could not find field [ {} ] on target [ {} ]" , fieldName , object . getClass ( ) . getSimpleName ( ) ) ; return ; } String methodName = "set" + CommUtil . capitalize ( fieldName ) ; Method method = ClassUtil . getDeclaredMethod ( object . getClass ( ) , recursively , methodName , value == null ? Object . class : value . getClass ( ) ) ; if ( method != null ) { try { makeAccessible ( method ) ; method . invoke ( object , value ) ; return ; } catch ( InvocationTargetException e ) { log . debug ( "Could not find method [ {} ] on target [ {} ]" , methodName , object . getClass ( ) . getSimpleName ( ) ) ; } catch ( NullPointerException e ) { log . debug ( "{} field: [ {} ] is null" , object . getClass ( ) . getSimpleName ( ) , fieldName ) ; } catch ( IllegalAccessException e ) { // Will not happen } } makeAccessible ( field ) ; try { field . set ( object , value ) ; } catch ( NullPointerException e ) { log . debug ( "{} field: [ {} ] is null" , object . getClass ( ) . getSimpleName ( ) , fieldName ) ; } catch ( IllegalAccessException e ) { // Will not happen } }
Direct writing the object attribute values, the private / protected
modifiers will be ignoring,if setter function exist,return setter
function value. <p>If recursively is true, will looking from all class
hierarchy</p>

@param object object
@param fieldName field name
@param value value
@param recursively recursively
Direct writing the object attribute values the private / protected modifiers will be ignoring if setter function exist return setter function value . <p > If recursively is true will looking from all class hierarchy< / p >