@Test public void testFailsetAuthor() { final Book book = new Book(); Assertions.assertThrows(Exception.class, () -> BeanUtil.setValue(book, "creator", "Mishima")); }
public static void setValue(final Object object, final String propertyName, final Object value) { Assertion.check() .isNotNull(object) .isNotNull(propertyName) .isTrue(propertyName.indexOf('.') == -1, "the dot notation is forbidden"); final PropertyDescriptor pd = getPropertyDescriptor(propertyName, object.getClass()); final Method writeMethod = pd.getWriteMethod(); if (writeMethod == null) { throw new VSystemException("no setter found for property '{0}' on class '{1}'", propertyName, object.getClass().getName()); } ClassUtil.invoke(object, writeMethod, value); }
BeanUtil { public static void setValue(final Object object, final String propertyName, final Object value) { Assertion.check() .isNotNull(object) .isNotNull(propertyName) .isTrue(propertyName.indexOf('.') == -1, "the dot notation is forbidden"); final PropertyDescriptor pd = getPropertyDescriptor(propertyName, object.getClass()); final Method writeMethod = pd.getWriteMethod(); if (writeMethod == null) { throw new VSystemException("no setter found for property '{0}' on class '{1}'", propertyName, object.getClass().getName()); } ClassUtil.invoke(object, writeMethod, value); } }
BeanUtil { public static void setValue(final Object object, final String propertyName, final Object value) { Assertion.check() .isNotNull(object) .isNotNull(propertyName) .isTrue(propertyName.indexOf('.') == -1, "the dot notation is forbidden"); final PropertyDescriptor pd = getPropertyDescriptor(propertyName, object.getClass()); final Method writeMethod = pd.getWriteMethod(); if (writeMethod == null) { throw new VSystemException("no setter found for property '{0}' on class '{1}'", propertyName, object.getClass().getName()); } ClassUtil.invoke(object, writeMethod, value); } private  BeanUtil(); }
BeanUtil { public static void setValue(final Object object, final String propertyName, final Object value) { Assertion.check() .isNotNull(object) .isNotNull(propertyName) .isTrue(propertyName.indexOf('.') == -1, "the dot notation is forbidden"); final PropertyDescriptor pd = getPropertyDescriptor(propertyName, object.getClass()); final Method writeMethod = pd.getWriteMethod(); if (writeMethod == null) { throw new VSystemException("no setter found for property '{0}' on class '{1}'", propertyName, object.getClass().getName()); } ClassUtil.invoke(object, writeMethod, value); } 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 void setValue(final Object object, final String propertyName, final Object value) { Assertion.check() .isNotNull(object) .isNotNull(propertyName) .isTrue(propertyName.indexOf('.') == -1, "the dot notation is forbidden"); final PropertyDescriptor pd = getPropertyDescriptor(propertyName, object.getClass()); final Method writeMethod = pd.getWriteMethod(); if (writeMethod == null) { throw new VSystemException("no setter found for property '{0}' on class '{1}'", propertyName, object.getClass().getName()); } ClassUtil.invoke(object, writeMethod, value); } 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);  }