Class EntryBuilder
Config entry.
This is an ergonomic, self-documenting alternative to the multi-argument
Config.set(String, Object, Serializer, String, String, List) overload. That overload packs several distinct
"leave-unchanged versus clear" sentinel conventions into one call (a
- Not calling a facet method leaves that facet untouched (no sentinel needed).
- An explicit setter (
comment(String),preLines(List),serializer(Serializer),modifiers(String)) sets that facet. - An explicit clear (
clearComment(),clearPreLines()) intentionally clears that facet rather than relying on a magic blank string or empty list.
The write is performed by the terminal set(Object) or set() method. The result is identical to the
equivalent Config.set(String, Object, Serializer, String, String, List) call.
Example:
Notes:
- This builder is not thread safe and is intended to be used and discarded within a single statement.
See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionExplicitly clears the same-line comment on the entry.Explicitly clears the pre-lines on the entry.Specifies the same-line comment to add to the entry.Specifies the modifiers to apply to the value (e.g.Specifies the comment or blank lines to add before the entry.serializer(Serializer value) Specifies the serializer to use to serialize the value.set()Adds or updates the entry using the value specified viavalue(Object).Adds or updates the entry using the specified value.Specifies the value to store on the entry.
-
Constructor Details
-
EntryBuilder
Constructor.- Parameters:
config- The config that the entry belongs to.key- The key of the entry to add or update.
Must not benull .
-
-
Method Details
-
value
Specifies the value to store on the entry.Equivalent to passing the value to the terminal
set(Object)method.- Parameters:
value- The new value POJO.
Serialized to a string using the registered (orspecified) serializer.- Returns:
- This object.
-
serializer
Specifies the serializer to use to serialize the value.If not called, the serializer registered on the config is used.
- Parameters:
value- The serializer to use for serializing the value.- Returns:
- This object.
-
modifiers
Specifies the modifiers to apply to the value (e.g."*" for encoded values).If not called, the modifiers on any existing entry are left untouched.
- Parameters:
value- The modifiers to apply to the value.- Returns:
- This object.
-
comment
Specifies the same-line comment to add to the entry.If not called, the comment on any existing entry is left untouched.
UseclearComment()to explicitly remove an existing comment.- Parameters:
value- The same-line comment to add to the entry. Must not benull (useclearComment()instead).- Returns:
- This object.
-
clearComment
Explicitly clears the same-line comment on the entry.- Returns:
- This object.
-
preLines
Specifies the comment or blank lines to add before the entry.If not called, the pre-lines on any existing entry are left untouched.
UseclearPreLines()to explicitly remove existing pre-lines.- Parameters:
value- The comment or blank lines to add before the entry. Must not benull (useclearPreLines()instead).- Returns:
- This object.
-
clearPreLines
Explicitly clears the pre-lines on the entry.- Returns:
- This object.
-
set
Adds or updates the entry using the value specified viavalue(Object).- Returns:
- The config that this builder belongs to.
- Throws:
SerializeException- If serializer could not serialize the value or if a serializer is not registered with this config file.UnsupportedOperationException- If configuration is read only.
-
set
Adds or updates the entry using the specified value.- Parameters:
value- The new value POJO.
Serialized to a string using the registered (orspecified) serializer.- Returns:
- The config that this builder belongs to.
- Throws:
SerializeException- If serializer could not serialize the value or if a serializer is not registered with this config file.UnsupportedOperationException- If configuration is read only.
-