Class InMemoryBackingStore

java.lang.Object
com.microsoft.kiota.store.InMemoryBackingStore
All Implemented Interfaces:
BackingStore

public class InMemoryBackingStore extends Object implements BackingStore
In-memory implementation of the backing store. Allows for dirty tracking of changes.
  • Constructor Details

    • InMemoryBackingStore

      public InMemoryBackingStore()
      Creates a new instance of the backing store.
  • Method Details

    • setIsInitializationCompleted

      public void setIsInitializationCompleted(boolean value)
      Description copied from interface: BackingStore
      Sets whether the initialization of the object and/or the initial deserialization has been completed to track whether objects have changed.
      Specified by:
      setIsInitializationCompleted in interface BackingStore
      Parameters:
      value - value to set
    • getIsInitializationCompleted

      public boolean getIsInitializationCompleted()
      Description copied from interface: BackingStore
      Gets whether the initialization of the object and/or the initial deserialization has been completed to track whether objects have changed.
      Specified by:
      getIsInitializationCompleted in interface BackingStore
      Returns:
      Whether the initialization of the object and/or the initial deserialization has been completed to track whether objects have changed.
    • setReturnOnlyChangedValues

      public void setReturnOnlyChangedValues(boolean value)
      Description copied from interface: BackingStore
      Sets whether to return only values that have changed since the initialization of the object when calling the Get and Enumerate methods.
      Specified by:
      setReturnOnlyChangedValues in interface BackingStore
      Parameters:
      value - value to set
    • getReturnOnlyChangedValues

      public boolean getReturnOnlyChangedValues()
      Description copied from interface: BackingStore
      Gets whether to return only values that have changed since the initialization of the object when calling the Get and Enumerate methods.
      Specified by:
      getReturnOnlyChangedValues in interface BackingStore
      Returns:
      Whether to return only values that have changed since the initialization of the object when calling the Get and Enumerate methods.
    • clear

      public void clear()
      Description copied from interface: BackingStore
      Clears the data stored in the backing store. Doesn't trigger any subscription.
      Specified by:
      clear in interface BackingStore
    • enumerate

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

      @Nonnull public Iterable<String> enumerateKeysForValuesChangedToNull()
      Description copied from interface: BackingStore
      Enumerates the keys for all values that changed to null.
      Specified by:
      enumerateKeysForValuesChangedToNull in interface BackingStore
      Returns:
      The keys for the values that changed to null.
    • get

      @Nullable public <T> T get(@Nonnull String key)
      Description copied from interface: BackingStore
      Gets a value from the backing store based on its key. Returns null if the value hasn't changed and "ReturnOnlyChangedValues" is true.
      Specified by:
      get in interface BackingStore
      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

      public <T> void set(@Nonnull String key, @Nullable T value)
      Description copied from interface: BackingStore
      Sets or updates the stored value for the given key. Will trigger subscriptions callbacks.
      Specified by:
      set in interface BackingStore
      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.
    • unsubscribe

      public void unsubscribe(@Nonnull String subscriptionId)
      Description copied from interface: BackingStore
      Removes a subscription from the store based on its subscription id.
      Specified by:
      unsubscribe in interface BackingStore
      Parameters:
      subscriptionId - The Id of the subscription to remove.
    • subscribe

      @Nonnull public String subscribe(@Nonnull TriConsumer<String,Object,Object> callback)
      Description copied from interface: BackingStore
      Creates a subscription to any data change happening.
      Specified by:
      subscribe in interface BackingStore
      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

      public void subscribe(@Nonnull String subscriptionId, @Nonnull TriConsumer<String,Object,Object> callback)
      Description copied from interface: BackingStore
      Creates a subscription to any data change happening, allowing to specify the subscription Id.
      Specified by:
      subscribe in interface BackingStore
      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.