Package org.incendo.cloud.key
Class SimpleMutableCloudKeyContainer
java.lang.Object
org.incendo.cloud.key.SimpleMutableCloudKeyContainer
- All Implemented Interfaces:
CloudKeyContainer,MutableCloudKeyContainer
@API(status=INTERNAL)
public final class SimpleMutableCloudKeyContainer
extends Object
implements MutableCloudKeyContainer
-
Constructor Summary
ConstructorsConstructorDescriptionSimpleMutableCloudKeyContainer(Map<CloudKey<?>, Object> map) Creates a newSimpleMutableCloudKeyContainer. -
Method Summary
Modifier and TypeMethodDescriptionall()Returns all stored values.<V> VcomputeIfAbsent(@NonNull CloudKey<V> key, @NonNull Function<@NonNull CloudKey<V>, V> defaultFunction) Returns the value associated with the givenkeyif it exists, else computes and stores the value returned by the givendefaultFunctionand then returns it.booleanReturns whether the registry contains a value associated with the givenkey.<V> @Nullable VGet the value, or null if not present, without boxing in an optional.Returns the value associated with the givenkey.Returns the value associated with the givenkey.voidRemoves value associated with the givenkey.<V> voidStores thekey-valuepair.<V> voidStores thekey-valuepair.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.incendo.cloud.key.CloudKeyContainer
contains, contains, get, get, get, getOrDefault, getOrDefault, getOrDefault, getOrSupplyDefault, getOrSupplyDefault, getOrSupplyDefault, optionalMethods inherited from interface org.incendo.cloud.key.MutableCloudKeyContainer
computeIfAbsent, remove, remove, set, set, set, store
-
Constructor Details
-
SimpleMutableCloudKeyContainer
Creates a newSimpleMutableCloudKeyContainer.- Parameters:
map- backing map
-
-
Method Details
-
optional
Description copied from interface:CloudKeyContainerReturns the value associated with the givenkey.- Specified by:
optionalin interfaceCloudKeyContainer- Type Parameters:
V- the type of the value- Parameters:
key- the key- Returns:
- the value
-
optional
Description copied from interface:CloudKeyContainerReturns the value associated with the givenkey.- Specified by:
optionalin interfaceCloudKeyContainer- Type Parameters:
V- the type of the value- Parameters:
key- the key- Returns:
- the value
-
contains
Description copied from interface:CloudKeyContainerReturns whether the registry contains a value associated with the givenkey.- Specified by:
containsin interfaceCloudKeyContainer- Parameters:
key- the key- Returns:
trueif the value exists, orfalseif it does not
-
all
Description copied from interface:CloudKeyContainerReturns all stored values.- Specified by:
allin interfaceCloudKeyContainer- Returns:
- immutable view of all values
-
store
Description copied from interface:MutableCloudKeyContainerStores thekey-valuepair.This will overwrite any existing value stored with the same
key.- Specified by:
storein interfaceMutableCloudKeyContainer- Type Parameters:
V- the type of the value- Parameters:
key- the keyvalue- the value
-
store
Description copied from interface:MutableCloudKeyContainerStores thekey-valuepair.This will overwrite any existing value stored with the same
key.- Specified by:
storein interfaceMutableCloudKeyContainer- Type Parameters:
V- the type of the value- Parameters:
key- the keyvalue- the value
-
remove
Description copied from interface:MutableCloudKeyContainerRemoves value associated with the givenkey.- Specified by:
removein interfaceMutableCloudKeyContainer- Parameters:
key- the key
-
computeIfAbsent
public <V> V computeIfAbsent(@NonNull CloudKey<V> key, @NonNull Function<@NonNull CloudKey<V>, V> defaultFunction) Description copied from interface:MutableCloudKeyContainerReturns the value associated with the givenkeyif it exists, else computes and stores the value returned by the givendefaultFunctionand then returns it.- Specified by:
computeIfAbsentin interfaceMutableCloudKeyContainer- Type Parameters:
V- the type of the value- Parameters:
key- the keydefaultFunction- the function used to generate the value in case it's missing- Returns:
- the present or computed value
-
getOrNull
Get the value, or null if not present, without boxing in an optional.- Type Parameters:
V- value type- Parameters:
key- key- Returns:
- value or null
-