/** * Get bean's property value. The sequence of searches for getting a value is as follows: * <ol> * <li>All class fields are found using {@link ClassUtils#getClassFields(Class)}</li> * <li>Search for a field with the name of the desired one is made</li> * <li>If a field is found and it's a non-public field, the value is returned using the accompanying getter</li> * <li>If a field is found and it's a public field, the value is returned using the public field</li> * <li>If a field is not found, a search for a getter is made - all class getters are found using * {@link ClassUtils#getClassFields(Class)}</li> * <li>From class getters, an appropriate getter with name of the desired one is used</li> * </ol> * * @param bean bean to be accessed * @param field bean's fieldName * @return bean's property value */ public static Object getProperty(Object bean, String field) { INSTANCE.checkParameters(bean, field); try { return INSTANCE.getPropertyValue(bean, field); } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { throw handleReflectionException(bean, field, e); } }
INSTANCE.checkParameters(bean, field);