Interface ModificationCounter
-
- All Known Implementing Classes:
IncrementalModificationCounter
public interface ModificationCounter
A counter of modification events of some objects (e.g., a collection, or a database view). It is updated each time the object notifies of an event. The clients that need to detect modifications must save the current value of the counter, and check if it has changed to determine if the corresponding source object is modified.Implementations must reliably detect up to 4 billion modifications (2^32-1).
Implementations are not required to be thread-safe.
-
-
Method Summary
Modifier and Type Method Description int
getCurrentValue()
Returns the current value of the counter.boolean
isModifiedSince(int lastValue)
Returns true if the counter was modified since the given value (ifnotifyModified()
has been invoked); false — otherwise.void
notifyModified()
Notifies this counter that the source object is modified, updating its current value.
-
-
-
Method Detail
-
isModifiedSince
boolean isModifiedSince(int lastValue)
Returns true if the counter was modified since the given value (ifnotifyModified()
has been invoked); false — otherwise.- Parameters:
lastValue
- the last value of the counter
-
getCurrentValue
int getCurrentValue()
Returns the current value of the counter. No assumptions must be made on how it changes when a notification is received.
-
notifyModified
void notifyModified()
Notifies this counter that the source object is modified, updating its current value.- Throws:
IllegalStateException
- if this counter corresponds to a read-only (immutable) object, i.e., must reject any modification events
-
-