Package com.microsoft.kiota.store
Class InMemoryBackingStore
java.lang.Object
com.microsoft.kiota.store.InMemoryBackingStore
- All Implemented Interfaces:
BackingStore
In-memory implementation of the backing store. Allows for dirty tracking of changes.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()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> TGets a value from the backing store based on its key.booleanGets whether the initialization of the object and/or the initial deserialization has been completed to track whether objects have changed.booleanGets whether to return only values that have changed since the initialization of the object when calling the Get and Enumerate methods.<T> voidSets or updates the stored value for the given key.voidsetIsInitializationCompleted(boolean value) Sets whether the initialization of the object and/or the initial deserialization has been completed to track whether objects have changed.voidsetReturnOnlyChangedValues(boolean value) Sets whether to return only values that have changed since the initialization of the object when calling the Get and Enumerate methods.subscribe(TriConsumer<String, Object, Object> callback) Creates a subscription to any data change happening.voidCreates a subscription to any data change happening, allowing to specify the subscription Id.voidunsubscribe(String subscriptionId) Removes a subscription from the store based on its subscription id.
-
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:BackingStoreSets whether the initialization of the object and/or the initial deserialization has been completed to track whether objects have changed.- Specified by:
setIsInitializationCompletedin interfaceBackingStore- Parameters:
value- value to set
-
getIsInitializationCompleted
public boolean getIsInitializationCompleted()Description copied from interface:BackingStoreGets whether the initialization of the object and/or the initial deserialization has been completed to track whether objects have changed.- Specified by:
getIsInitializationCompletedin interfaceBackingStore- 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:BackingStoreSets whether to return only values that have changed since the initialization of the object when calling the Get and Enumerate methods.- Specified by:
setReturnOnlyChangedValuesin interfaceBackingStore- Parameters:
value- value to set
-
getReturnOnlyChangedValues
public boolean getReturnOnlyChangedValues()Description copied from interface:BackingStoreGets whether to return only values that have changed since the initialization of the object when calling the Get and Enumerate methods.- Specified by:
getReturnOnlyChangedValuesin interfaceBackingStore- 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:BackingStoreClears the data stored in the backing store. Doesn't trigger any subscription.- Specified by:
clearin interfaceBackingStore
-
enumerate
Description copied from interface:BackingStoreEnumerates all the values stored in the backing store. Values will be filtered if "ReturnOnlyChangedValues" is true.- Specified by:
enumeratein interfaceBackingStore- Returns:
- The values available in the backing store.
-
enumerateKeysForValuesChangedToNull
Description copied from interface:BackingStoreEnumerates the keys for all values that changed to null.- Specified by:
enumerateKeysForValuesChangedToNullin interfaceBackingStore- Returns:
- The keys for the values that changed to null.
-
get
Description copied from interface:BackingStoreGets a value from the backing store based on its key. Returns null if the value hasn't changed and "ReturnOnlyChangedValues" is true.- Specified by:
getin interfaceBackingStore- 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
Description copied from interface:BackingStoreSets or updates the stored value for the given key. Will trigger subscriptions callbacks.- Specified by:
setin interfaceBackingStore- 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
Description copied from interface:BackingStoreRemoves a subscription from the store based on its subscription id.- Specified by:
unsubscribein interfaceBackingStore- Parameters:
subscriptionId- The Id of the subscription to remove.
-
subscribe
Description copied from interface:BackingStoreCreates a subscription to any data change happening.- Specified by:
subscribein interfaceBackingStore- 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:BackingStoreCreates a subscription to any data change happening, allowing to specify the subscription Id.- Specified by:
subscribein interfaceBackingStore- 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.
-