Class ImmutableMap.Builder<K,V>
java.lang.Object
software.amazon.awssdk.utils.ImmutableMap.Builder<K,V>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionallowDuplicateKeys
(boolean allowDuplicateKeys) Sets whether duplicate keys are allowed.build()
Generates and returns a new ImmutableMap instance which contains all the entries added into the Builder byput()
method.Add a key-value pair into the built map.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
put
Add a key-value pair into the built map. The method will throw IllegalArgumentException immediately when duplicate keys are provided and allowDuplicateKeys is false (default value). If duplicate keys are provided and allowDuplicateKeys is true, the latest value will overwrite the existing value, and the SDK will log a message at WARN level.- Returns:
- Returns a reference to this object so that method calls can be chained together.
-
allowDuplicateKeys
Sets whether duplicate keys are allowed. If true, the latest value will overwrite the existing value. If false, an error will be thrown when attempting to put an entry with a duplicate key. Default value is false.- Returns:
- Returns a reference to this object so that method calls can be chained together.
-
build
Generates and returns a new ImmutableMap instance which contains all the entries added into the Builder byput()
method.
-