Class NestedText.Builder

java.lang.Object
org.loxlylabs.nestedtext.NestedText.Builder
Enclosing class:
NestedText

public static class NestedText.Builder extends Object
A builder class to assist in creating NestedText instances.
  • Method Details

    • registerDeserializer

      public <T> NestedText.Builder registerDeserializer(Class<T> type, Deserializer<T> deserializer)
      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 a String, Map, or List to an instance of the class.
      Returns:
      This builder instance for chaining.
    • registerSerializer

      public <T> NestedText.Builder registerSerializer(Class<T> type, Serializer<T> serializer)
      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 a String, Map, or List.
      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

      public NestedText.Builder endOfLine(String eol)
      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

      public NestedText.Builder indentAmount(int indent)
      Configures default indentation to use when dumping NestedText
      Parameters:
      indent - the indent amount
      Returns:
      This builder instance for chaining.
    • build

      public NestedText build()
      Builds an immutable NestedText instance with the configured settings.
      Returns:
      A new NestedText instance.