@Test(expected = IllegalStateException.class) public void testWrongType() { Person person = new Person(); Binding<String> nameBinding = new PropertyBinding<String>(person, "age"); nameBinding.setValue("Tom"); }
@Override public void setValue(T value) { try { PropertyUtils.setSimpleProperty(boundObject, property, value); } catch (Exception e) { throw new IllegalStateException(String.format( "Binding error! Setting property '%s' on bound object of class %s failed!", property, boundObject.getClass()), e); } }
PropertyBinding implements Binding<T> { @Override public void setValue(T value) { try { PropertyUtils.setSimpleProperty(boundObject, property, value); } catch (Exception e) { throw new IllegalStateException(String.format( "Binding error! Setting property '%s' on bound object of class %s failed!", property, boundObject.getClass()), e); } } }
PropertyBinding implements Binding<T> { @Override public void setValue(T value) { try { PropertyUtils.setSimpleProperty(boundObject, property, value); } catch (Exception e) { throw new IllegalStateException(String.format( "Binding error! Setting property '%s' on bound object of class %s failed!", property, boundObject.getClass()), e); } } PropertyBinding(Object boundObject, String property); }
PropertyBinding implements Binding<T> { @Override public void setValue(T value) { try { PropertyUtils.setSimpleProperty(boundObject, property, value); } catch (Exception e) { throw new IllegalStateException(String.format( "Binding error! Setting property '%s' on bound object of class %s failed!", property, boundObject.getClass()), e); } } PropertyBinding(Object boundObject, String property); @Override void setValue(T value); @Override @SuppressWarnings("unchecked") T getValue(); }
PropertyBinding implements Binding<T> { @Override public void setValue(T value) { try { PropertyUtils.setSimpleProperty(boundObject, property, value); } catch (Exception e) { throw new IllegalStateException(String.format( "Binding error! Setting property '%s' on bound object of class %s failed!", property, boundObject.getClass()), e); } } PropertyBinding(Object boundObject, String property); @Override void setValue(T value); @Override @SuppressWarnings("unchecked") T getValue();  }