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 Detail

      • isModifiedSince

        boolean isModifiedSince​(int lastValue)
        Returns true if the counter was modified since the given value (if notifyModified() 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:
        java.lang.IllegalStateException - if this counter corresponds to a read-only (immutable) object, i.e., must reject any modification events