@Test public void testFailgetAuthor() { final Book book = new Book(); book.setAuthor("Murakami"); Assertions.assertThrows(Exception.class, () -> BeanUtil.getValue(book, "creator")); }
public static Object getValue(final Object object, final String propertyName) { Assertion.check() .isNotNull(object) .isNotNull(propertyName) .isTrue(propertyName.indexOf('.') == -1, "the dot notation is forbidden"); final PropertyDescriptor pd = getPropertyDescriptor(propertyName, object.getClass()); final Method readMethod = pd.getReadMethod(); if (readMethod == null) { throw new VSystemException("no getter found for property '{0}' on class '{1}'", propertyName, object.getClass().getName()); } return ClassUtil.invoke(object, readMethod); }
BeanUtil { public static Object getValue(final Object object, final String propertyName) { Assertion.check() .isNotNull(object) .isNotNull(propertyName) .isTrue(propertyName.indexOf('.') == -1, "the dot notation is forbidden"); final PropertyDescriptor pd = getPropertyDescriptor(propertyName, object.getClass()); final Method readMethod = pd.getReadMethod(); if (readMethod == null) { throw new VSystemException("no getter found for property '{0}' on class '{1}'", propertyName, object.getClass().getName()); } return ClassUtil.invoke(object, readMethod); } }
BeanUtil { public static Object getValue(final Object object, final String propertyName) { Assertion.check() .isNotNull(object) .isNotNull(propertyName) .isTrue(propertyName.indexOf('.') == -1, "the dot notation is forbidden"); final PropertyDescriptor pd = getPropertyDescriptor(propertyName, object.getClass()); final Method readMethod = pd.getReadMethod(); if (readMethod == null) { throw new VSystemException("no getter found for property '{0}' on class '{1}'", propertyName, object.getClass().getName()); } return ClassUtil.invoke(object, readMethod); } private  BeanUtil(); }
BeanUtil { public static Object getValue(final Object object, final String propertyName) { Assertion.check() .isNotNull(object) .isNotNull(propertyName) .isTrue(propertyName.indexOf('.') == -1, "the dot notation is forbidden"); final PropertyDescriptor pd = getPropertyDescriptor(propertyName, object.getClass()); final Method readMethod = pd.getReadMethod(); if (readMethod == null) { throw new VSystemException("no getter found for property '{0}' on class '{1}'", propertyName, object.getClass().getName()); } return ClassUtil.invoke(object, readMethod); } private  BeanUtil(); static Object getValue(final Object object, final String propertyName); static void setValue(final Object object, final String propertyName, final Object value); static PropertyDescriptor getPropertyDescriptor(final String propertyName, final Class<?> beanClass); }
BeanUtil { public static Object getValue(final Object object, final String propertyName) { Assertion.check() .isNotNull(object) .isNotNull(propertyName) .isTrue(propertyName.indexOf('.') == -1, "the dot notation is forbidden"); final PropertyDescriptor pd = getPropertyDescriptor(propertyName, object.getClass()); final Method readMethod = pd.getReadMethod(); if (readMethod == null) { throw new VSystemException("no getter found for property '{0}' on class '{1}'", propertyName, object.getClass().getName()); } return ClassUtil.invoke(object, readMethod); } private  BeanUtil(); static Object getValue(final Object object, final String propertyName); static void setValue(final Object object, final String propertyName, final Object value); static PropertyDescriptor getPropertyDescriptor(final String propertyName, final Class<?> beanClass);  }