@Test public void hasChanged() { final Property<String> targetOne = new StaticValueProperty<>("Static"); final IDependencyObject<String> depOne = new PropertyBasedDependencyObject<>(targetOne, "Default"); Assert.assertTrue(depOne.hasChanged(new DummyInjectionTarget())); Assert.assertEquals("Static", depOne.get(new DummyInjectionTarget())); Assert.assertFalse(depOne.hasChanged(new DummyInjectionTarget())); depOne.set(new DummyInjectionTarget(), "Changed"); Assert.assertTrue(depOne.hasChanged(new DummyInjectionTarget())); }
@Override public boolean hasChanged(@Nullable final Object context) { final T resolved = property.apply(context).orElse(def); final int currentHash = resolved == null ? 0 : resolved.hashCode(); return lastResolvedHash != currentHash; }
PropertyBasedDependencyObject implements IDependencyObject<T> { @Override public boolean hasChanged(@Nullable final Object context) { final T resolved = property.apply(context).orElse(def); final int currentHash = resolved == null ? 0 : resolved.hashCode(); return lastResolvedHash != currentHash; } }
PropertyBasedDependencyObject implements IDependencyObject<T> { @Override public boolean hasChanged(@Nullable final Object context) { final T resolved = property.apply(context).orElse(def); final int currentHash = resolved == null ? 0 : resolved.hashCode(); return lastResolvedHash != currentHash; } PropertyBasedDependencyObject(@NotNull final Property<T> property, @Nullable final T def); }
PropertyBasedDependencyObject implements IDependencyObject<T> { @Override public boolean hasChanged(@Nullable final Object context) { final T resolved = property.apply(context).orElse(def); final int currentHash = resolved == null ? 0 : resolved.hashCode(); return lastResolvedHash != currentHash; } PropertyBasedDependencyObject(@NotNull final Property<T> property, @Nullable final T def); @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); }
PropertyBasedDependencyObject implements IDependencyObject<T> { @Override public boolean hasChanged(@Nullable final Object context) { final T resolved = property.apply(context).orElse(def); final int currentHash = resolved == null ? 0 : resolved.hashCode(); return lastResolvedHash != currentHash; } PropertyBasedDependencyObject(@NotNull final Property<T> property, @Nullable final T def); @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);  }