### Question:
ReflectionHelper { @Nullable public static <T> T propertyValueByName(Object targetObject, String propertyName, Class<T> clazz) { try { PropertyDescriptor desc = PropertyUtils.getPropertyDescriptor(targetObject, propertyName); Object result = invokeMethod(desc.getReadMethod(), targetObject); return (T)result; } catch (IllegalAccessException e) { throw new IllegalStateException("Could not invoke " + propertyName, e); } catch (InvocationTargetException e) { throw new IllegalStateException("Could not invoke " + propertyName, e); } catch (NoSuchMethodException e) { throw new IllegalStateException("Could not invoke " + propertyName, e); } }  static boolean hasAnnotation(Method method, Class<A> annotationType); @Nullable static A findAnnotation(Method method, Class<A> annotationType); @Nullable static A findAnnotation(Class<?> clazz, Class<A> annotationType); @Nullable static Object invokeMethod(Method method, Object target); static Set<Method> getterMethods(Class<?> clazz); static String propertyNameOfGetter(Method method); @Nullable static T propertyValueByName(Object targetObject, String propertyName, Class<T> clazz); @Nullable static Method propertyGetter(Object obj, String propertyName);  }### Answer:
@Test public void testPropertyValueByName() { assertEquals("var", ReflectionHelper.propertyValueByName(childAObj, "var", String.class)); assertEquals(false, ReflectionHelper.propertyValueByName(childAObj, "var2", boolean.class)); }