@Test(expectedExceptions = IllegalStateException.class, expectedExceptionsMessageRegExp = "There are 2 with name 'superField' in this class hierarchy!") public void shouldComplainAboutDuplicatedFields() { Object value = Integer.valueOf("1"); Object secondValue = Integer.valueOf("2"); RichObject richObject = new RichObject(new MyObjectWithDuplicatedField(value, secondValue)); richObject.get("superField"); }
public Object get(String propertyName) { try { Field f = getFieldWithName(propertyName); f.setAccessible(true); return f.get(wrapped); } catch (IllegalAccessException e) { throw new RuntimeException(e); } }
RichObject { public Object get(String propertyName) { try { Field f = getFieldWithName(propertyName); f.setAccessible(true); return f.get(wrapped); } catch (IllegalAccessException e) { throw new RuntimeException(e); } } }
RichObject { public Object get(String propertyName) { try { Field f = getFieldWithName(propertyName); f.setAccessible(true); return f.get(wrapped); } catch (IllegalAccessException e) { throw new RuntimeException(e); } } RichObject(Object wrapped); }
RichObject { public Object get(String propertyName) { try { Field f = getFieldWithName(propertyName); f.setAccessible(true); return f.get(wrapped); } catch (IllegalAccessException e) { throw new RuntimeException(e); } } RichObject(Object wrapped); RichObject set(String propertyName, Object value); @Deprecated RichObject setSuper(String propertyName, Object value); Object get(String propertyName); @Deprecated Object getSuper(String propertyName); Object unwrap(); }
RichObject { public Object get(String propertyName) { try { Field f = getFieldWithName(propertyName); f.setAccessible(true); return f.get(wrapped); } catch (IllegalAccessException e) { throw new RuntimeException(e); } } RichObject(Object wrapped); RichObject set(String propertyName, Object value); @Deprecated RichObject setSuper(String propertyName, Object value); Object get(String propertyName); @Deprecated Object getSuper(String propertyName); Object unwrap();  }