Interface MapInterceptor

  • All Superinterfaces:
    java.io.Serializable

    public interface MapInterceptor
    extends java.io.Serializable
    MapInterceptor is used to intercept changes to the map, allowing access to the values before and after adding them to the map.

    MapInterceptors are chained when added to the map, which means that when an interceptor is added on node initialization, it could be added twice. To prevent this, make sure to implement the hashCode method to return the same value for every instance of the class.

    Serialized instances of this interface are used in client-member communication, so changing an implementation's binary format will render it incompatible with its previous versions.

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void afterGet​(java.lang.Object value)
      Called after the get(...) operation is completed.
      void afterPut​(java.lang.Object value)
      Called after the put(...) operation is completed.
      void afterRemove​(java.lang.Object oldValue)
      Called after the remove(...) operation is completed.
      java.lang.Object interceptGet​(java.lang.Object value)
      Intercepts the get operation before returning value.
      java.lang.Object interceptPut​(java.lang.Object oldValue, java.lang.Object newValue)
      Intercepts the put operation before modifying the map data.
      java.lang.Object interceptRemove​(java.lang.Object removedValue)
      Intercepts the remove operation before removing the data.
    • Method Detail

      • interceptGet

        java.lang.Object interceptGet​(java.lang.Object value)
        Intercepts the get operation before returning value.

        Returns another object to change the return value of get(...) operations. Returning null will cause the get(...) operation to return the original value, so return null if you do not want to change anything.

        Mutations made to the value do not affect the stored value. They do affect the returned value.

        Parameters:
        value - the original value to be returned as the result of get(...) operation
        Returns:
        the new value that will be returned by the get(...) operation
      • afterGet

        void afterGet​(java.lang.Object value)
        Called after the get(...) operation is completed.

        Mutations made to value do not affect the stored value.

        Parameters:
        value - the value returned as the result of the get(...) operation
      • interceptPut

        java.lang.Object interceptPut​(java.lang.Object oldValue,
                                      java.lang.Object newValue)
        Intercepts the put operation before modifying the map data.

        Returns the object to be put into the map. Returning null will cause the put(...) operation to operate as expected, namely no interception. Throwing an exception will cancel the put operation.

        Parameters:
        oldValue - the value currently in map
        newValue - the new value to be put into the map
        Returns:
        new value after the intercept operation
      • afterPut

        void afterPut​(java.lang.Object value)
        Called after the put(...) operation is completed.
        Parameters:
        value - the value returned as the result of the put(...) operation
      • interceptRemove

        java.lang.Object interceptRemove​(java.lang.Object removedValue)
        Intercepts the remove operation before removing the data.

        Returns the object to be returned as the result of the remove operation. Throwing an exception will cancel the remove operation.

        Parameters:
        removedValue - the existing value to be removed
        Returns:
        the value to be returned as the result of remove operation
      • afterRemove

        void afterRemove​(java.lang.Object oldValue)
        Called after the remove(...) operation is completed.
        Parameters:
        oldValue - the value returned as the result of the remove(...) operation