@Test public void newInstanceIsDirtyWorks() { SampleClass enhanced = enhancer.newInstance(); assertDirty(enhanced, true); ((Snapshot) enhanced).snapshot(); assertDirty(enhanced, false); enhanced.setFoo("foo"); assertDirty(enhanced, true); ((Snapshot) enhanced).snapshot(); assertDirty(enhanced, false); enhanced.setFoo(null); assertDirty(enhanced, true); enhanced.setFoo("bar"); assertDirty(enhanced, true); enhanced.setFoo("foo"); assertDirty(enhanced, false); }
public T newInstance() { try { return getEnhancedClass().newInstance(); } catch (Exception e) { logger.error("Could not instantiate enhanced object.", e); throw ExceptionUtil.propagate(e); } }
Enhancer { public T newInstance() { try { return getEnhancedClass().newInstance(); } catch (Exception e) { logger.error("Could not instantiate enhanced object.", e); throw ExceptionUtil.propagate(e); } } }
Enhancer { public T newInstance() { try { return getEnhancedClass().newInstance(); } catch (Exception e) { logger.error("Could not instantiate enhanced object.", e); throw ExceptionUtil.propagate(e); } } protected  Enhancer(Class<T> baseClass); }
Enhancer { public T newInstance() { try { return getEnhancedClass().newInstance(); } catch (Exception e) { logger.error("Could not instantiate enhanced object.", e); throw ExceptionUtil.propagate(e); } } protected  Enhancer(Class<T> baseClass); abstract boolean needsEnhancement(Object object); void validateClassIsEnhanceable(Class<T> baseClass); final Class<T> getBaseClass(); Class<? extends T> getEnhancedClass(); T newInstance(); T enhance(T t); }
Enhancer { public T newInstance() { try { return getEnhancedClass().newInstance(); } catch (Exception e) { logger.error("Could not instantiate enhanced object.", e); throw ExceptionUtil.propagate(e); } } protected  Enhancer(Class<T> baseClass); abstract boolean needsEnhancement(Object object); void validateClassIsEnhanceable(Class<T> baseClass); final Class<T> getBaseClass(); Class<? extends T> getEnhancedClass(); T newInstance(); T enhance(T t);  }