Class IndentConfig


  • public final class IndentConfig
    extends java.lang.Object
    Configuration for JSON output indentation.

    Specifies the character to use for indentation (space or tab) and how many times to repeat it per indentation level.

    Author:
    Chris Burdess
    • Constructor Summary

      Constructors 
      Constructor Description
      IndentConfig​(char indentChar, int indentCount)
      Creates an indent configuration.
    • Constructor Detail

      • IndentConfig

        public IndentConfig​(char indentChar,
                            int indentCount)
        Creates an indent configuration.
        Parameters:
        indentChar - the character to use for indentation (' ' or '\t')
        indentCount - how many times to repeat the character per level (must be positive)
        Throws:
        java.lang.IllegalArgumentException - if indentChar is not space or tab, or if count is not positive
    • Method Detail

      • getIndentChar

        public char getIndentChar()
        Returns the character to use for indentation.
        Returns:
        the indent character (' ' or '\t')
      • getIndentCount

        public int getIndentCount()
        Returns how many times to repeat the indent character per level.
        Returns:
        the indent count
      • tabs

        public static IndentConfig tabs()
        Creates an indent configuration using tabs.
        Returns:
        configuration for single tab per level
      • spaces2

        public static IndentConfig spaces2()
        Creates an indent configuration using 2 spaces per level.
        Returns:
        configuration for 2 spaces per level
      • spaces4

        public static IndentConfig spaces4()
        Creates an indent configuration using 4 spaces per level.
        Returns:
        configuration for 4 spaces per level
      • spaces

        public static IndentConfig spaces​(int count)
        Creates an indent configuration using the specified number of spaces per level.
        Parameters:
        count - the number of spaces per level
        Returns:
        configuration for the specified number of spaces per level
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object