Class ToStringStyle.JsonToStringStyle

java.lang.Object
org.apache.commons.lang3.builder.ToStringStyle
org.apache.commons.lang3.builder.ToStringStyle.JsonToStringStyle
All Implemented Interfaces:
Serializable
Enclosing class:
ToStringStyle

private static final class ToStringStyle.JsonToStringStyle extends ToStringStyle
ToStringStyle that outputs with JSON format.

This is an inner class rather than using StandardToStringStyle to ensure its immutability.

Since:
3.4
See Also:
  • Field Details

  • Constructor Details

    • JsonToStringStyle

      JsonToStringStyle()
      Constructs a new instance.

      Use the static constant rather than instantiating.

  • Method Details

    • append

      public void append(StringBuffer buffer, String fieldName, boolean[] array, Boolean fullDetail)
      Description copied from class: ToStringStyle
      Appends to the toString a boolean array.
      Overrides:
      append in class ToStringStyle
      Parameters:
      buffer - the StringBuffer to populate
      fieldName - the field name
      array - the array to add to the toString
      fullDetail - true for detail, false for summary info, null for style decides
    • append

      public void append(StringBuffer buffer, String fieldName, byte[] array, Boolean fullDetail)
      Description copied from class: ToStringStyle
      Appends to the toString a byte array.
      Overrides:
      append in class ToStringStyle
      Parameters:
      buffer - the StringBuffer to populate
      fieldName - the field name
      array - the array to add to the toString
      fullDetail - true for detail, false for summary info, null for style decides
    • append

      public void append(StringBuffer buffer, String fieldName, char[] array, Boolean fullDetail)
      Description copied from class: ToStringStyle
      Appends to the toString a char array.
      Overrides:
      append in class ToStringStyle
      Parameters:
      buffer - the StringBuffer to populate
      fieldName - the field name
      array - the array to add to the toString
      fullDetail - true for detail, false for summary info, null for style decides
    • append

      public void append(StringBuffer buffer, String fieldName, double[] array, Boolean fullDetail)
      Description copied from class: ToStringStyle
      Appends to the toString a double array.
      Overrides:
      append in class ToStringStyle
      Parameters:
      buffer - the StringBuffer to populate
      fieldName - the field name
      array - the array to add to the toString
      fullDetail - true for detail, false for summary info, null for style decides
    • append

      public void append(StringBuffer buffer, String fieldName, float[] array, Boolean fullDetail)
      Description copied from class: ToStringStyle
      Appends to the toString a float array.
      Overrides:
      append in class ToStringStyle
      Parameters:
      buffer - the StringBuffer to populate
      fieldName - the field name
      array - the array to add to the toString
      fullDetail - true for detail, false for summary info, null for style decides
    • append

      public void append(StringBuffer buffer, String fieldName, int[] array, Boolean fullDetail)
      Description copied from class: ToStringStyle
      Appends to the toString an int array.
      Overrides:
      append in class ToStringStyle
      Parameters:
      buffer - the StringBuffer to populate
      fieldName - the field name
      array - the array to add to the toString
      fullDetail - true for detail, false for summary info, null for style decides
    • append

      public void append(StringBuffer buffer, String fieldName, long[] array, Boolean fullDetail)
      Description copied from class: ToStringStyle
      Appends to the toString a long array.
      Overrides:
      append in class ToStringStyle
      Parameters:
      buffer - the StringBuffer to populate
      fieldName - the field name
      array - the array to add to the toString
      fullDetail - true for detail, false for summary info, null for style decides
    • append

      public void append(StringBuffer buffer, String fieldName, Object value, Boolean fullDetail)
      Description copied from class: ToStringStyle
      Appends to the toString an Object value, printing the full toString of the Object passed in.
      Overrides:
      append in class ToStringStyle
      Parameters:
      buffer - the StringBuffer to populate
      fieldName - the field name
      value - the value to add to the toString
      fullDetail - true for detail, false for summary info, null for style decides
    • append

      public void append(StringBuffer buffer, String fieldName, Object[] array, Boolean fullDetail)
      Description copied from class: ToStringStyle
      Appends to the toString an Object array.
      Overrides:
      append in class ToStringStyle
      Parameters:
      buffer - the StringBuffer to populate
      fieldName - the field name
      array - the array to add to the toString
      fullDetail - true for detail, false for summary info, null for style decides
    • append

      public void append(StringBuffer buffer, String fieldName, short[] array, Boolean fullDetail)
      Description copied from class: ToStringStyle
      Appends to the toString a short array.
      Overrides:
      append in class ToStringStyle
      Parameters:
      buffer - the StringBuffer to populate
      fieldName - the field name
      array - the array to add to the toString
      fullDetail - true for detail, false for summary info, null for style decides
    • appendDetail

      protected void appendDetail(StringBuffer buffer, String fieldName, char value)
      Description copied from class: ToStringStyle
      Appends to the toString a char value.
      Overrides:
      appendDetail in class ToStringStyle
      Parameters:
      buffer - the StringBuffer to populate
      fieldName - the field name, typically not used as already appended
      value - the value to add to the toString
    • appendDetail

      protected void appendDetail(StringBuffer buffer, String fieldName, Collection<?> coll)
      Description copied from class: ToStringStyle
      Appends to the toString a Collection.
      Overrides:
      appendDetail in class ToStringStyle
      Parameters:
      buffer - the StringBuffer to populate
      fieldName - the field name, typically not used as already appended
      coll - the Collection to add to the toString, not null
    • appendDetail

      protected void appendDetail(StringBuffer buffer, String fieldName, Map<?,?> map)
      Description copied from class: ToStringStyle
      Appends to the toString a Map.
      Overrides:
      appendDetail in class ToStringStyle
      Parameters:
      buffer - the StringBuffer to populate
      fieldName - the field name, typically not used as already appended
      map - the Map to add to the toString, not null
    • appendDetail

      protected void appendDetail(StringBuffer buffer, String fieldName, Object value)
      Description copied from class: ToStringStyle
      Appends to the toString an Object value, printing the full detail of the Object.
      Overrides:
      appendDetail in class ToStringStyle
      Parameters:
      buffer - the StringBuffer to populate
      fieldName - the field name, typically not used as already appended
      value - the value to add to the toString, not null
    • appendFieldStart

      protected void appendFieldStart(StringBuffer buffer, String fieldName)
      Description copied from class: ToStringStyle
      Appends to the toString the field start.
      Overrides:
      appendFieldStart in class ToStringStyle
      Parameters:
      buffer - the StringBuffer to populate
      fieldName - the field name
    • appendValueAsString

      private void appendValueAsString(StringBuffer buffer, String value)
      Appends the given String enclosed in double-quotes to the given StringBuffer.
      Parameters:
      buffer - the StringBuffer to append the value to.
      value - the value to append.
    • isJsonArray

      private boolean isJsonArray(String valueAsString)
    • isJsonObject

      private boolean isJsonObject(String valueAsString)
    • readResolve

      private Object readResolve()
      Ensure Singleton after serialization.
      Returns:
      the singleton