Permalink
Browse files

Document that counter fields don't generate change notifications.

  • Loading branch information...
archiecobbs committed Nov 8, 2017
1 parent 89a2de4 commit 601a93bf49fefd62c772f1e447587d0f99ffa777
@@ -12,8 +12,8 @@
import java.lang.annotation.Target;
/**
* Annotation for methods that are to be invoked whenever a target field in some target object changes during a transaction,
* where the target object containing the changed field is found at the end of a path of references
* Annotation for methods that are to be invoked whenever a simple or complext target field in some target object changes
* during a transaction, where the target object containing the changed field is found at the end of a path of references
* starting from the object to be notified.
* See {@link io.permazen.ReferencePath} for more information about reference paths.
*
@@ -219,6 +219,9 @@
* <p><b>Other Notes</b></p>
*
* <p>
* {@link io.permazen.Counter} fields do not generate change notifications.
*
* <p>
* No notifications are delivered for "changes" that do not actually change anything (e.g., setting a simple field to
* the value already contained in that field, or adding an element to a set which is already contained in the set).
*
@@ -299,6 +299,16 @@ public void testInverseRestrictedTypes() {
}
}
@Test
public void testCounter() {
try {
BasicTest.getPermazen(HasCounter.class);
assert false;
} catch (java.lang.IllegalArgumentException e) {
// expected
}
}
private void verify(FieldChange<?>... changes) {
Assert.assertEquals(EVENTS.get(), Arrays.asList(changes), "\nACTUAL: " + EVENTS.get()
+ "\nEXPECTED: " + Arrays.asList(changes));
@@ -683,5 +693,17 @@ private void onChange(SimpleFieldChange<D, Integer> change) {
public abstract int getFoo();
public abstract void setFoo(int x);
}
}
// Counter Test
@PermazenType
public abstract static class HasCounter implements JObject {
public abstract Counter getCounter();
@OnChange("counter")
private void onChange(Change<HasCounter> change) {
throw new RuntimeException("unexpected notification");
}
}
}

0 comments on commit 601a93b

Please sign in to comment.