TransformingDependencyObject implements IDependencyObject<T> { @Override public boolean hasChanged(@Nullable final Object context) { final T resolved = getTransformer.apply(inputDependency.get(context)); final int resolvedHash = resolved == null ? 0 : resolved.hashCode(); return resolvedHash != lastResolvedHash; } TransformingDependencyObject(
      final IDependencyObject<I> inputDependency,
      final Function<I, T> getTransformer,
      final Function<T, I> setTransformer); @Override boolean requiresDataContext(); @Nullable @Override T get(@Nullable final Object context); @Override void set(@Nullable final Object context, @Nullable final T value); @Override boolean hasChanged(@Nullable final Object context);  }
@Test public void hasChanged() { final IDependencyObject<String> input = new StaticDependencyObject<>("Input"); final IDependencyObject<String> target = new TransformingDependencyObject<>(input, s -> s.replace("In", "Out"), s -> s.replace("Out", "In")); Assert.assertTrue(target.hasChanged(new DummyInjectionTarget())); Assert.assertEquals("Output", target.get(new DummyInjectionTarget())); Assert.assertFalse(target.hasChanged(new DummyInjectionTarget())); target.set(new DummyInjectionTarget(), "Test"); Assert.assertTrue(target.hasChanged(new DummyInjectionTarget())); Assert.assertEquals("Test", target.get(new DummyInjectionTarget())); Assert.assertFalse(target.hasChanged(new DummyInjectionTarget())); Assert.assertFalse(target.hasChanged(new DummyInjectionTarget())); target.set(new DummyInjectionTarget(), "Output"); Assert.assertTrue(target.hasChanged(new DummyInjectionTarget())); Assert.assertTrue(target.hasChanged(new DummyInjectionTarget())); Assert.assertEquals("Input", input.get(new DummyInjectionTarget())); Assert.assertEquals("Output", target.get(new DummyInjectionTarget())); Assert.assertFalse(target.hasChanged(new DummyInjectionTarget())); }