Package org.loxlylabs.nestedtext
Class NestedText.Builder
java.lang.Object
org.loxlylabs.nestedtext.NestedText.Builder
- Enclosing class:
NestedText
A builder class to assist in creating NestedText instances.
-
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds an immutableNestedTextinstance with the configured settings.Configures default end of line separator to use when dumping NestedTextforType(Class<T> type, Consumer<NestedText.TypeConfiguration<T>> config) Provides a fluent API for configuring serialization and deserialization rules for a specific class without modifying the class itself.indentAmount(int indent) Configures default indentation to use when dumping NestedTextregisterDeserializer(Class<T> type, Deserializer<T> deserializer) Registers a custom deserializer for deserializing a value to specific class.registerSerializer(Class<T> type, Serializer<T> serializer) Registers a custom serializer for serializing a specific class to a NestedText-compatible format.
-
Method Details
-
registerDeserializer
Registers a custom deserializer for deserializing a value to specific class.- Type Parameters:
T- The type of the class.- Parameters:
type- The class type to register the deserializer for.deserializer- The adapter that converts aString,Map, orListto an instance of the class.- Returns:
- This builder instance for chaining.
-
registerSerializer
Registers a custom serializer for serializing a specific class to a NestedText-compatible format.- Type Parameters:
T- The type of the class.- Parameters:
type- The class type to register the serializer for.serializer- The adapter that converts an instance of the class to aString,Map, orList.- Returns:
- This builder instance for chaining.
-
forType
public <T> NestedText.Builder forType(Class<T> type, Consumer<NestedText.TypeConfiguration<T>> config) Provides a fluent API for configuring serialization and deserialization rules for a specific class without modifying the class itself.- Type Parameters:
T- The type being configured.- Parameters:
type- The class to configure.config- A lambda expression to define the configuration rules.- Returns:
- This builder instance for chaining.
-
endOfLine
Configures default end of line separator to use when dumping NestedText- Parameters:
eol- the end of line separator- Returns:
- This builder instance for chaining.
-
indentAmount
Configures default indentation to use when dumping NestedText- Parameters:
indent- the indent amount- Returns:
- This builder instance for chaining.
-
build
Builds an immutableNestedTextinstance with the configured settings.- Returns:
- A new
NestedTextinstance.
-