Interface BackingStore

All Known Implementing Classes:
InMemoryBackingStore

public interface BackingStore
Stores model information in a different location than the object properties. Implementations can provide dirty tracking capabilities, caching capabilities or integration with 3rd party stores.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Clears the data stored in the backing store.
    Enumerates all the values stored in the backing store.
    Enumerates the keys for all values that changed to null.
    <T> T
    get(String key)
    Gets a value from the backing store based on its key.
    boolean
    Gets whether the initialization of the object and/or the initial deserialization has been completed to track whether objects have changed.
    boolean
    Gets whether to return only values that have changed since the initialization of the object when calling the Get and Enumerate methods.
    <T> void
    set(String key, T value)
    Sets or updates the stored value for the given key.
    void
    Sets whether the initialization of the object and/or the initial deserialization has been completed to track whether objects have changed.
    void
    Sets whether to return only values that have changed since the initialization of the object when calling the Get and Enumerate methods.
    Creates a subscription to any data change happening.
    void
    subscribe(String subscriptionId, TriConsumer<String,Object,Object> callback)
    Creates a subscription to any data change happening, allowing to specify the subscription Id.
    void
    unsubscribe(String subscriptionId)
    Removes a subscription from the store based on its subscription id.
  • Method Details

    • get

      @Nullable <T> T get(@Nonnull String key)
      Gets a value from the backing store based on its key. Returns null if the value hasn't changed and "ReturnOnlyChangedValues" is true.
      Type Parameters:
      T - The type of the value to be retrieved.
      Parameters:
      key - The key to lookup the backing store with.
      Returns:
      The value from the backing store.
    • set

      <T> void set(@Nonnull String key, @Nullable T value)
      Sets or updates the stored value for the given key. Will trigger subscriptions callbacks.
      Type Parameters:
      T - The type of the value to be stored.
      Parameters:
      key - The key to store and retrieve the information.
      value - The value to be stored.
    • enumerate

      @Nonnull Map<String,Object> enumerate()
      Enumerates all the values stored in the backing store. Values will be filtered if "ReturnOnlyChangedValues" is true.
      Returns:
      The values available in the backing store.
    • enumerateKeysForValuesChangedToNull

      @Nonnull Iterable<String> enumerateKeysForValuesChangedToNull()
      Enumerates the keys for all values that changed to null.
      Returns:
      The keys for the values that changed to null.
    • subscribe

      @Nonnull String subscribe(@Nonnull TriConsumer<String,Object,Object> callback)
      Creates a subscription to any data change happening.
      Parameters:
      callback - Callback to be invoked on data changes where the first parameter is the data key, the second the previous value and the third the new value.
      Returns:
      The subscription Id to use when removing the subscription
    • subscribe

      void subscribe(@Nonnull String subscriptionId, @Nonnull TriConsumer<String,Object,Object> callback)
      Creates a subscription to any data change happening, allowing to specify the subscription Id.
      Parameters:
      subscriptionId - The subscription Id to use.
      callback - Callback to be invoked on data changes where the first parameter is the data key, the second the previous value and the third the new value.
    • unsubscribe

      void unsubscribe(@Nonnull String subscriptionId)
      Removes a subscription from the store based on its subscription id.
      Parameters:
      subscriptionId - The Id of the subscription to remove.
    • clear

      void clear()
      Clears the data stored in the backing store. Doesn't trigger any subscription.
    • setIsInitializationCompleted

      void setIsInitializationCompleted(boolean value)
      Sets whether the initialization of the object and/or the initial deserialization has been completed to track whether objects have changed.
      Parameters:
      value - value to set
    • getIsInitializationCompleted

      boolean getIsInitializationCompleted()
      Gets whether the initialization of the object and/or the initial deserialization has been completed to track whether objects have changed.
      Returns:
      Whether the initialization of the object and/or the initial deserialization has been completed to track whether objects have changed.
    • setReturnOnlyChangedValues

      void setReturnOnlyChangedValues(boolean value)
      Sets whether to return only values that have changed since the initialization of the object when calling the Get and Enumerate methods.
      Parameters:
      value - value to set
    • getReturnOnlyChangedValues

      boolean getReturnOnlyChangedValues()
      Gets whether to return only values that have changed since the initialization of the object when calling the Get and Enumerate methods.
      Returns:
      Whether to return only values that have changed since the initialization of the object when calling the Get and Enumerate methods.