Class DittoCborSerializable.Dictionary.Builder
java.lang.Object
com.ditto.java.serialization.DittoCborSerializable.Dictionary.Builder
- Enclosing class:
DittoCborSerializable.Dictionary
Builder for constructing CBOR dictionaries.
Use the various put() methods to add key-value pairs to the dictionary,
then call build() to create the immutable DittoCborSerializable.Dictionary.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription@NonNull DittoCborSerializable.Dictionarybuild()Builds the immutableDittoCborSerializable.Dictionaryfrom the accumulated key-value pairs.put(@NonNull DittoCborSerializable key, @NonNull DittoAttachment attachment) Adds a key-value pair where the key is CBOR-serializable and the value is an attachment.put(@NonNull DittoCborSerializable key, @NonNull DittoCborSerializable value) Adds a key-value pair where both are CBOR-serializable values.Adds a string key with a boolean value.Adds a string key with a byte array value.Adds a string key with a double value.Adds a string key with a float value.Adds a string key with an int value.Adds a string key with a long value.put(@NonNull String key, @NonNull DittoAttachment attachment) Adds a key-value pair where the key is a string and the value is an attachment.put(@NonNull String key, @NonNull DittoCborSerializable value) Adds a key-value pair where the key is a string and the value is CBOR-serializable.Adds a string key-value pair.putAll(@NonNull DittoCborSerializable.Dictionary other) Adds all key-value pairs from another dictionary.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
put
public @NonNull DittoCborSerializable.Dictionary.Builder put(@NonNull DittoCborSerializable key, @NonNull DittoCborSerializable value) Adds a key-value pair where both are CBOR-serializable values.- Parameters:
key- the key.value- the value.- Returns:
- this builder for method chaining.
-
put
public @NonNull DittoCborSerializable.Dictionary.Builder put(@NonNull DittoCborSerializable key, @NonNull DittoAttachment attachment) Adds a key-value pair where the key is CBOR-serializable and the value is an attachment.- Parameters:
key- the key.attachment- the attachment value.- Returns:
- this builder for method chaining.
-
put
public @NonNull DittoCborSerializable.Dictionary.Builder put(@NonNull String key, @NonNull DittoAttachment attachment) Adds a key-value pair where the key is a string and the value is an attachment.- Parameters:
key- the string key.attachment- the attachment value.- Returns:
- this builder for method chaining.
-
put
public @NonNull DittoCborSerializable.Dictionary.Builder put(@NonNull String key, @NonNull DittoCborSerializable value) Adds a key-value pair where the key is a string and the value is CBOR-serializable.- Parameters:
key- the string key.value- the value.- Returns:
- this builder for method chaining.
-
put
public @NonNull DittoCborSerializable.Dictionary.Builder put(@NonNull String key, @NonNull String value) Adds a string key-value pair.- Parameters:
key- the string key.value- the string value.- Returns:
- this builder for method chaining.
-
put
Adds a string key with an int value.- Parameters:
key- the string key.value- the int value.- Returns:
- this builder for method chaining.
-
put
Adds a string key with a long value.- Parameters:
key- the string key.value- the long value.- Returns:
- this builder for method chaining.
-
put
Adds a string key with a float value.- Parameters:
key- the string key.value- the float value.- Returns:
- this builder for method chaining.
-
put
Adds a string key with a double value.- Parameters:
key- the string key.value- the double value.- Returns:
- this builder for method chaining.
-
put
Adds a string key with a boolean value.- Parameters:
key- the string key.value- the boolean value.- Returns:
- this builder for method chaining.
-
put
public @NonNull DittoCborSerializable.Dictionary.Builder put(@NonNull String key, byte @NonNull [] value) Adds a string key with a byte array value.- Parameters:
key- the string key.value- the byte array value.- Returns:
- this builder for method chaining.
-
putAll
public @NonNull DittoCborSerializable.Dictionary.Builder putAll(@NonNull DittoCborSerializable.Dictionary other) Adds all key-value pairs from another dictionary.- Parameters:
other- the dictionary to copy entries from.- Returns:
- this builder for method chaining.
-
build
Builds the immutableDittoCborSerializable.Dictionaryfrom the accumulated key-value pairs.- Returns:
- the constructed dictionary.
-