Interface ResourceEventHandler<T>

  • Type Parameters:
    T - resource

    public interface ResourceEventHandler<T>
    ResourceEventHandler can handle notifications for events that happen to a resource. The events are information only, so you can't return an error.
    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      void onAdd​(T obj)
      Called when an object is added.
      void onDelete​(T obj, boolean deletedFinalStateUnknown)
      Gets the final state of the item if it is known, otherwise it would get an object of the DeletedFinalStateUnknown.
      default void onNothing()
      Called after an empty list is retrieved on start or after an HTTP GONE when the Store is empty
      void onUpdate​(T oldObj, T newObj)
      Called when an object is modified.
    • Method Detail

      • onNothing

        default void onNothing()
        Called after an empty list is retrieved on start or after an HTTP GONE when the Store is empty

        Should not be implemented with long-running logic as that may lead to memory issues.

      • onAdd

        void onAdd​(T obj)
        Called when an object is added.

        Should not be implemented with long-running logic as that may lead to memory issues.

        Parameters:
        obj - object
      • onUpdate

        void onUpdate​(T oldObj,
                      T newObj)
        Called when an object is modified. Note that oldObj is the last known state of the object -- it is possible that several changes were combined together, so you can't use this to see every single change. It is also called when a sync happens - oldObj will be the same as newObj.

        Should not be implemented with long-running logic as that may lead to memory issues.

        Parameters:
        oldObj - old object
        newObj - new object
      • onDelete

        void onDelete​(T obj,
                      boolean deletedFinalStateUnknown)
        Gets the final state of the item if it is known, otherwise it would get an object of the DeletedFinalStateUnknown. This can happen if the watch is closed and misses the delete event and we don't notice the deletion until the subsequent re-list.

        Should not be implemented with long-running logic as that may lead to memory issues.

        Parameters:
        obj - object to delete
        deletedFinalStateUnknown - get final state of item if it is known or not.