Class DumpSettingsBuilder

java.lang.Object
org.snakeyaml.engine.v2.api.DumpSettingsBuilder

public final class DumpSettingsBuilder extends Object
Builder pattern implementation for DumpSettings
  • Field Details

    • customProperties

      Map<SettingKey,Object> customProperties
    • explicitStart

      private boolean explicitStart
    • explicitEnd

      private boolean explicitEnd
    • nonPrintableStyle

      private NonPrintableStyle nonPrintableStyle
    • explicitRootTag

      private Optional<Tag> explicitRootTag
    • anchorGenerator

      private AnchorGenerator anchorGenerator
    • yamlDirective

      private Optional<SpecVersion> yamlDirective
    • tagDirective

      private Map<String,String> tagDirective
    • defaultFlowStyle

      private FlowStyle defaultFlowStyle
    • defaultScalarStyle

      private ScalarStyle defaultScalarStyle
    • canonical

      private boolean canonical
    • multiLineFlow

      private boolean multiLineFlow
    • useUnicodeEncoding

      private boolean useUnicodeEncoding
    • indent

      private int indent
    • indicatorIndent

      private int indicatorIndent
    • width

      private int width
    • bestLineBreak

      private String bestLineBreak
    • splitLines

      private boolean splitLines
    • maxSimpleKeyLength

      private int maxSimpleKeyLength
    • indentWithIndicator

      private boolean indentWithIndicator
    • dumpComments

      private boolean dumpComments
    • schema

      private Schema schema
  • Constructor Details

    • DumpSettingsBuilder

      DumpSettingsBuilder()
      Create builder
  • Method Details

    • setDefaultFlowStyle

      public DumpSettingsBuilder setDefaultFlowStyle(FlowStyle defaultFlowStyle)
      Define flow style
      Parameters:
      defaultFlowStyle - - specify the style
      Returns:
      the builder with the provided value
    • setDefaultScalarStyle

      public DumpSettingsBuilder setDefaultScalarStyle(ScalarStyle defaultScalarStyle)
      Define default scalar style
      Parameters:
      defaultScalarStyle - - specify the scalar style
      Returns:
      the builder with the provided value
    • setExplicitStart

      public DumpSettingsBuilder setExplicitStart(boolean explicitStart)
      Add '---' in the beginning of the document
      Parameters:
      explicitStart - - true if the document start must be explicitly indicated
      Returns:
      the builder with the provided value
    • setAnchorGenerator

      public DumpSettingsBuilder setAnchorGenerator(AnchorGenerator anchorGenerator)
      Define anchor name generator (by default 'id' + number)
      Parameters:
      anchorGenerator - - specified function to create anchor names
      Returns:
      the builder with the provided value
    • setExplicitRootTag

      public DumpSettingsBuilder setExplicitRootTag(Optional<Tag> explicitRootTag)
      Define root Tag or let the tag to be detected automatically
      Parameters:
      explicitRootTag - - specify the root tag
      Returns:
      the builder with the provided value
    • setExplicitEnd

      public DumpSettingsBuilder setExplicitEnd(boolean explicitEnd)
      Add '...' in the end of the document
      Parameters:
      explicitEnd - - true if the document end must be explicitly indicated
      Returns:
      the builder with the provided value
    • setYamlDirective

      public DumpSettingsBuilder setYamlDirective(Optional<SpecVersion> yamlDirective)
      Add YAML directive
      Parameters:
      yamlDirective - - the version to be used in the directive
      Returns:
      the builder with the provided value
    • setTagDirective

      public DumpSettingsBuilder setTagDirective(Map<String,String> tagDirective)
      Add TAG directive
      Parameters:
      tagDirective - - the data to create TAG directive
      Returns:
      the builder with the provided value
    • setCanonical

      public DumpSettingsBuilder setCanonical(boolean canonical)
      Enforce canonical representation
      Parameters:
      canonical - - specify if the canonical representation must be used
      Returns:
      the builder with the provided value
    • setMultiLineFlow

      public DumpSettingsBuilder setMultiLineFlow(boolean multiLineFlow)
      Use pretty flow style when every value in the flow context gets a separate line.
      Parameters:
      multiLineFlow - - set false to output all values in a single line.
      Returns:
      the builder with the provided value
    • setUseUnicodeEncoding

      public DumpSettingsBuilder setUseUnicodeEncoding(boolean useUnicodeEncoding)
      Specify whether to emit non-ASCII printable Unicode characters (emit Unicode char or escape sequence starting with '\\u') The default value is true. When set to false then printable non-ASCII characters (Cyrillic, Chinese etc) will be not printed but escaped (to support ASCII terminals)
      Parameters:
      useUnicodeEncoding - - true to use Unicode for "Я", false to use "Ч" for the same char (if useUnicodeEncoding is false then all non-ASCII characters are escaped)
      Returns:
      the builder with the provided value
    • setIndent

      public DumpSettingsBuilder setIndent(int indent)
      Define the amount of the spaces for the indent in the block flow style. Default is 2.
      Parameters:
      indent - - the number of spaces. Must be within the range org.snakeyaml.engine.v2.emitter.Emitter.MIN_INDENT and org.snakeyaml.engine.v2.emitter.Emitter.MAX_INDENT
      Returns:
      the builder with the provided value
    • setIndicatorIndent

      public DumpSettingsBuilder setIndicatorIndent(int indicatorIndent)
      It adds the specified indent for sequence indicator in the block flow. Default is 0. For better visual results it should be by 2 less than the indent (which is 2 by default) It is 2 chars less because the first char is '-' and the second char is the space after it.
      Parameters:
      indicatorIndent - - must be non-negative and less than org.snakeyaml.engine.v2.emitter.Emitter.MAX_INDENT - 1
      Returns:
      the builder with the provided value
    • setWidth

      public DumpSettingsBuilder setWidth(int width)
      Set max width for literal scalars. When the scalar representation takes more then the preferred with the scalar will be split into a few lines. The default is 80.
      Parameters:
      width - - the width
      Returns:
      the builder with the provided value
    • setBestLineBreak

      public DumpSettingsBuilder setBestLineBreak(String bestLineBreak)
      If the YAML is created for another platform (for instance on Windows to be consumed under Linux) than this setting is used to define the line ending. The platform line end is used by default.
      Parameters:
      bestLineBreak - - "\r\n" or "\n"
      Returns:
      the builder with the provided value
    • setSplitLines

      public DumpSettingsBuilder setSplitLines(boolean splitLines)
      Define whether to split long lines
      Parameters:
      splitLines - - true to split long lines
      Returns:
      the builder with the provided value
    • setMaxSimpleKeyLength

      public DumpSettingsBuilder setMaxSimpleKeyLength(int maxSimpleKeyLength)
      Define max key length to use simple key (without '?'). More info
      Parameters:
      maxSimpleKeyLength - - the limit after which the key gets explicit key indicator '?'
      Returns:
      the builder with the provided value
    • setNonPrintableStyle

      public DumpSettingsBuilder setNonPrintableStyle(NonPrintableStyle nonPrintableStyle)
      When String object contains non-printable characters, they are escaped with \\u or \\x notation. Sometimes it is better to transform this data to binary (with the !!binary tag). String objects with printable data are non affected by this setting.
      Parameters:
      nonPrintableStyle - - set this to BINARY to force non-printable String to represented as binary (byte array)
      Returns:
      the builder with the provided value
    • setCustomProperty

      public DumpSettingsBuilder setCustomProperty(SettingKey key, Object value)
      Custom property is the way to give some runtime parameters to be used during dumping
      Parameters:
      key - - the key
      value - - the value behind the key
      Returns:
      the builder with the provided value
    • setIndentWithIndicator

      public DumpSettingsBuilder setIndentWithIndicator(boolean indentWithIndicator)
      Set to true to add the indent for sequences to the general indent
      Parameters:
      indentWithIndicator - - true when indent for sequences is added to general
      Returns:
      the builder with the provided value
    • setDumpComments

      public DumpSettingsBuilder setDumpComments(boolean dumpComments)
      Set to true to add comments from Nodes to
      Parameters:
      dumpComments - - true when comments should be dumped (serialised)
      Returns:
      the builder with the provided value
    • setSchema

      public DumpSettingsBuilder setSchema(Schema schema)
      Provide either recommended or custom schema instead of default JsonSchema. These 3 are available FailsafeSchema, JsonSchema, CoreSchema.
      Parameters:
      schema - - the tag schema
      Returns:
      the builder with the provided value
    • build

      public DumpSettings build()
      Create immutable DumpSettings
      Returns:
      DumpSettings with the provided values