core/src/main/java/org/springframework/security/util/FieldUtils.java
public static Object getFieldValue(Object bean, String fieldName)
			throws IllegalAccessException {
		Assert.notNull(bean, "Bean cannot be null");
		Assert.hasText(fieldName, "Field name required");
		String[] nestedFields = StringUtils.tokenizeToStringArray(fieldName, ".");
		Class<?> componentClass = bean.getClass();
		Object value = bean;

		for (String nestedField : nestedFields) {
			Field field = getField(componentClass, nestedField);
			field.setAccessible(true);
			value = field.get(value);
			if (value != null) {
				componentClass = value.getClass();
			}
		}

		return value;

	}
public static Object getFieldValue(Object bean, String fieldName)
			throws IllegalAccessException {
		Assert.notNull(bean, "Bean cannot be null");
		Assert.hasText(fieldName, "Field name required");
		String[] nestedFields = StringUtils.tokenizeToStringArray(fieldName, ".");
		Class<?> componentClass = bean.getClass();
		Object value = bean;

		for (String nestedField : nestedFields) {
			Field field = getField(componentClass, nestedField);
			field.setAccessible(true);
			value = field.get(value);
			if (value != null) {
				componentClass = value.getClass();
			}
		}

		return value;

	}
public static Object getFieldValue ( Object bean , String fieldName ) throws IllegalAccessException { Assert . notNull ( bean , "Bean cannot be null" ) ; Assert . hasText ( fieldName , "Field name required" ) ; String [ ] nestedFields = StringUtils . tokenizeToStringArray ( fieldName , "." ) ; Class < ? > componentClass = bean . getClass ( ) ; Object value = bean ; for ( String nestedField : nestedFields ) { Field field = getField ( componentClass , nestedField ) ; field . setAccessible ( true ) ; value = field . get ( value ) ; if ( value != null ) { componentClass = value . getClass ( ) ; } } return value ; }
Returns the value of a (nested) field on a bean. Intended for testing.
@param bean the object
@param fieldName the field name, with "." separating nested properties
@return the value of the nested field
Returns the value of a ( nested ) field on a bean . Intended for testing .