NonSelfRegisteringSettableValue extends AbstractMonitorable<T> { public void set(T newValue) { Preconditions.checkNotNull(newValue, "Monitored value can not be null"); if (Objects.equal(this.value, newValue)) { return; } this.value = newValue; notifyMonitors(); } @SuppressWarnings({"unchecked", "PMD.ExcessiveParameterList"})  NonSelfRegisteringSettableValue(String name, String description, Unit<?> unit, T initialValue, ValueSemantics valueSemantics); @Override T get(); void set(T newValue);  }
@Test public void monitorsWillBeNotifiedWhenTheValueChanges() { value.attachMonitor(monitor); value.set(NEW_VALUE); verify(monitor).valueChanged(value); }
@Test public void monitorsWillNotBeNotifiedWhenTheValueDoesNotChange() { value.attachMonitor(monitor); value.set(INITIAL_VALUE); verify(monitor, never()).valueChanged(value); }