StandardToStringStyle.java

  1. /*
  2.  * Licensed to the Apache Software Foundation (ASF) under one or more
  3.  * contributor license agreements.  See the NOTICE file distributed with
  4.  * this work for additional information regarding copyright ownership.
  5.  * The ASF licenses this file to You under the Apache License, Version 2.0
  6.  * (the "License"); you may not use this file except in compliance with
  7.  * the License.  You may obtain a copy of the License at
  8.  *
  9.  *      http://www.apache.org/licenses/LICENSE-2.0
  10.  *
  11.  * Unless required by applicable law or agreed to in writing, software
  12.  * distributed under the License is distributed on an "AS IS" BASIS,
  13.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.  * See the License for the specific language governing permissions and
  15.  * limitations under the License.
  16.  */
  17. package org.apache.commons.lang3.builder;

  18. import java.lang.reflect.Array;
  19. import java.util.Collection;
  20. import java.util.Map;

  21. /**
  22.  * Works with {@link ToStringBuilder} to create a {@code toString}.
  23.  *
  24.  * <p>This class is intended to be used as a singleton.
  25.  * There is no need to instantiate a new style each time.
  26.  * Simply instantiate the class once, customize the values as required, and
  27.  * store the result in a public static final variable for the rest of the
  28.  * program to access.</p>
  29.  *
  30.  * @since 1.0
  31.  */
  32. public class StandardToStringStyle extends ToStringStyle {

  33.     /**
  34.      * Required for serialization support.
  35.      *
  36.      * @see java.io.Serializable
  37.      */
  38.     private static final long serialVersionUID = 1L;

  39.     /**
  40.      * Constructs a new instance.
  41.      */
  42.     public StandardToStringStyle() {
  43.     }

  44.     /**
  45.      * Gets the array end text.
  46.      *
  47.      * @return the current array end text
  48.      */
  49.     @Override
  50.     public String getArrayEnd() {
  51.         return super.getArrayEnd();
  52.     }

  53.     /**
  54.      * Gets the array separator text.
  55.      *
  56.      * @return the current array separator text
  57.      */
  58.     @Override
  59.     public String getArraySeparator() {
  60.         return super.getArraySeparator();
  61.     }

  62.     /**
  63.      * Gets the array start text.
  64.      *
  65.      * @return the current array start text
  66.      */
  67.     @Override
  68.     public String getArrayStart() {
  69.         return super.getArrayStart();
  70.     }

  71.     /**
  72.      * Gets the content end text.
  73.      *
  74.      * @return the current content end text
  75.      */
  76.     @Override
  77.     public String getContentEnd() {
  78.         return super.getContentEnd();
  79.     }

  80.     /**
  81.      * Gets the content start text.
  82.      *
  83.      * @return the current content start text
  84.      */
  85.     @Override
  86.     public String getContentStart() {
  87.         return super.getContentStart();
  88.     }

  89.     /**
  90.      * Gets the field name value separator text.
  91.      *
  92.      * @return the current field name value separator text
  93.      */
  94.     @Override
  95.     public String getFieldNameValueSeparator() {
  96.         return super.getFieldNameValueSeparator();
  97.     }

  98.     /**
  99.      * Gets the field separator text.
  100.      *
  101.      * @return the current field separator text
  102.      */
  103.     @Override
  104.     public String getFieldSeparator() {
  105.         return super.getFieldSeparator();
  106.     }

  107.     /**
  108.      * Gets the text to output when {@code null} found.
  109.      *
  110.      * @return the current text to output when {@code null} found
  111.      */
  112.     @Override
  113.     public String getNullText() {
  114.         return super.getNullText();
  115.     }

  116.     /**
  117.      * Gets the end text to output when a {@link Collection},
  118.      * {@link Map} or {@link Array} size is output.
  119.      *
  120.      * <p>This is output after the size value.</p>
  121.      *
  122.      * @return the current end of size text
  123.      */
  124.     @Override
  125.     public String getSizeEndText() {
  126.         return super.getSizeEndText();
  127.     }

  128.     /**
  129.      * Gets the text to output when a {@link Collection},
  130.      * {@link Map} or {@link Array} size is output.
  131.      *
  132.      * <p>This is output before the size value.</p>
  133.      *
  134.      * @return the current start of size text
  135.      */
  136.     @Override
  137.     public String getSizeStartText() {
  138.         return super.getSizeStartText();
  139.     }

  140.     /**
  141.      * Gets the end text to output when an {@link Object} is
  142.      * output in summary mode.
  143.      *
  144.      * <p>This is output after the size value.</p>
  145.      *
  146.      * @return the current end of summary text
  147.      */
  148.     @Override
  149.     public String getSummaryObjectEndText() {
  150.         return super.getSummaryObjectEndText();
  151.     }

  152.     /**
  153.      * Gets the start text to output when an {@link Object} is
  154.      * output in summary mode.
  155.      *
  156.      * <p>This is output before the size value.</p>
  157.      *
  158.      * @return the current start of summary text
  159.      */
  160.     @Override
  161.     public String getSummaryObjectStartText() {
  162.         return super.getSummaryObjectStartText();
  163.     }

  164.     /**
  165.      * Gets whether to output array content detail.
  166.      *
  167.      * @return the current array content detail setting
  168.      */
  169.     @Override
  170.     public boolean isArrayContentDetail() {
  171.         return super.isArrayContentDetail();
  172.     }

  173.     /**
  174.      * Gets whether to use full detail when the caller doesn't
  175.      * specify.
  176.      *
  177.      * @return the current defaultFullDetail flag
  178.      */
  179.     @Override
  180.     public boolean isDefaultFullDetail() {
  181.         return super.isDefaultFullDetail();
  182.     }

  183.     /**
  184.      * Gets whether the field separator should be added at the end
  185.      * of each buffer.
  186.      *
  187.      * @return fieldSeparatorAtEnd flag
  188.      * @since 2.0
  189.      */
  190.     @Override
  191.     public boolean isFieldSeparatorAtEnd() {
  192.         return super.isFieldSeparatorAtEnd();
  193.     }

  194.     /**
  195.      * Gets whether the field separator should be added at the start
  196.      * of each buffer.
  197.      *
  198.      * @return the fieldSeparatorAtStart flag
  199.      * @since 2.0
  200.      */
  201.     @Override
  202.     public boolean isFieldSeparatorAtStart() {
  203.         return super.isFieldSeparatorAtStart();
  204.     }

  205.     /**
  206.      * Gets whether to use the class name.
  207.      *
  208.      * @return the current useClassName flag
  209.      */
  210.     @Override
  211.     public boolean isUseClassName() {
  212.         return super.isUseClassName();
  213.     }

  214.     /**
  215.      * Gets whether to use the field names passed in.
  216.      *
  217.      * @return the current useFieldNames flag
  218.      */
  219.     @Override
  220.     public boolean isUseFieldNames() {
  221.         return super.isUseFieldNames();
  222.     }

  223.     /**
  224.      * Gets whether to use the identity hash code.
  225.      * @return the current useIdentityHashCode flag
  226.      */
  227.     @Override
  228.     public boolean isUseIdentityHashCode() {
  229.         return super.isUseIdentityHashCode();
  230.     }

  231.     /**
  232.      * Gets whether to output short or long class names.
  233.      *
  234.      * @return the current useShortClassName flag
  235.      * @since 2.0
  236.      */
  237.     @Override
  238.     public boolean isUseShortClassName() {
  239.         return super.isUseShortClassName();
  240.     }

  241.     /**
  242.      * Sets whether to output array content detail.
  243.      *
  244.      * @param arrayContentDetail  the new arrayContentDetail flag
  245.      */
  246.     @Override
  247.     public void setArrayContentDetail(final boolean arrayContentDetail) {
  248.         super.setArrayContentDetail(arrayContentDetail);
  249.     }

  250.     /**
  251.      * Sets the array end text.
  252.      *
  253.      * <p>{@code null} is accepted, but will be converted
  254.      * to an empty String.</p>
  255.      *
  256.      * @param arrayEnd  the new array end text
  257.      */
  258.     @Override
  259.     public void setArrayEnd(final String arrayEnd) {
  260.         super.setArrayEnd(arrayEnd);
  261.     }

  262.     /**
  263.      * Sets the array separator text.
  264.      *
  265.      * <p>{@code null} is accepted, but will be converted
  266.      * to an empty String.</p>
  267.      *
  268.      * @param arraySeparator  the new array separator text
  269.      */
  270.     @Override
  271.     public void setArraySeparator(final String arraySeparator) {
  272.         super.setArraySeparator(arraySeparator);
  273.     }

  274.     /**
  275.      * Sets the array start text.
  276.      *
  277.      * <p>{@code null} is accepted, but will be converted
  278.      * to an empty String.</p>
  279.      *
  280.      * @param arrayStart  the new array start text
  281.      */
  282.     @Override
  283.     public void setArrayStart(final String arrayStart) {
  284.         super.setArrayStart(arrayStart);
  285.     }

  286.     /**
  287.      * Sets the content end text.
  288.      *
  289.      * <p>{@code null} is accepted, but will be converted
  290.      * to an empty String.</p>
  291.      *
  292.      * @param contentEnd  the new content end text
  293.      */
  294.     @Override
  295.     public void setContentEnd(final String contentEnd) {
  296.         super.setContentEnd(contentEnd);
  297.     }

  298.     /**
  299.      * Sets the content start text.
  300.      *
  301.      * <p>{@code null} is accepted, but will be converted
  302.      * to an empty String.</p>
  303.      *
  304.      * @param contentStart  the new content start text
  305.      */
  306.     @Override
  307.     public void setContentStart(final String contentStart) {
  308.         super.setContentStart(contentStart);
  309.     }

  310.     /**
  311.      * Sets whether to use full detail when the caller doesn't
  312.      * specify.
  313.      *
  314.      * @param defaultFullDetail  the new defaultFullDetail flag
  315.      */
  316.     @Override
  317.     public void setDefaultFullDetail(final boolean defaultFullDetail) {
  318.         super.setDefaultFullDetail(defaultFullDetail);
  319.     }

  320.     /**
  321.      * Sets the field name value separator text.
  322.      *
  323.      * <p>{@code null} is accepted, but will be converted
  324.      * to an empty String.</p>
  325.      *
  326.      * @param fieldNameValueSeparator  the new field name value separator text
  327.      */
  328.     @Override
  329.     public void setFieldNameValueSeparator(final String fieldNameValueSeparator) {
  330.         super.setFieldNameValueSeparator(fieldNameValueSeparator);
  331.     }

  332.     /**
  333.      * Sets the field separator text.
  334.      *
  335.      * <p>{@code null} is accepted, but will be converted
  336.      * to an empty String.</p>
  337.      *
  338.      * @param fieldSeparator  the new field separator text
  339.      */
  340.     @Override
  341.     public void setFieldSeparator(final String fieldSeparator) {
  342.         super.setFieldSeparator(fieldSeparator);
  343.     }

  344.     /**
  345.      * Sets whether the field separator should be added at the end
  346.      * of each buffer.
  347.      *
  348.      * @param fieldSeparatorAtEnd  the fieldSeparatorAtEnd flag
  349.      * @since 2.0
  350.      */
  351.     @Override
  352.     public void setFieldSeparatorAtEnd(final boolean fieldSeparatorAtEnd) {
  353.         super.setFieldSeparatorAtEnd(fieldSeparatorAtEnd);
  354.     }

  355.     /**
  356.      * Sets whether the field separator should be added at the start
  357.      * of each buffer.
  358.      *
  359.      * @param fieldSeparatorAtStart  the fieldSeparatorAtStart flag
  360.      * @since 2.0
  361.      */
  362.     @Override
  363.     public void setFieldSeparatorAtStart(final boolean fieldSeparatorAtStart) {
  364.         super.setFieldSeparatorAtStart(fieldSeparatorAtStart);
  365.     }

  366.     /**
  367.      * Sets the text to output when {@code null} found.
  368.      *
  369.      * <p>{@code null} is accepted, but will be converted
  370.      * to an empty String.</p>
  371.      *
  372.      * @param nullText  the new text to output when {@code null} found
  373.      */
  374.     @Override
  375.     public void setNullText(final String nullText) {
  376.         super.setNullText(nullText);
  377.     }

  378.     /**
  379.      * Sets the end text to output when a {@link Collection},
  380.      * {@link Map} or {@link Array} size is output.
  381.      *
  382.      * <p>This is output after the size value.</p>
  383.      *
  384.      * <p>{@code null} is accepted, but will be converted
  385.      * to an empty String.</p>
  386.      *
  387.      * @param sizeEndText  the new end of size text
  388.      */
  389.     @Override
  390.     public void setSizeEndText(final String sizeEndText) {
  391.         super.setSizeEndText(sizeEndText);
  392.     }

  393.     /**
  394.      * Sets the start text to output when a {@link Collection},
  395.      * {@link Map} or {@link Array} size is output.
  396.      *
  397.      * <p>This is output before the size value.</p>
  398.      *
  399.      * <p>{@code null} is accepted, but will be converted to
  400.      * an empty String.</p>
  401.      *
  402.      * @param sizeStartText  the new start of size text
  403.      */
  404.     @Override
  405.     public void setSizeStartText(final String sizeStartText) {
  406.         super.setSizeStartText(sizeStartText);
  407.     }

  408.     /**
  409.      * Sets the end text to output when an {@link Object} is
  410.      * output in summary mode.
  411.      *
  412.      * <p>This is output after the size value.</p>
  413.      *
  414.      * <p>{@code null} is accepted, but will be converted to
  415.      * an empty String.</p>
  416.      *
  417.      * @param summaryObjectEndText  the new end of summary text
  418.      */
  419.     @Override
  420.     public void setSummaryObjectEndText(final String summaryObjectEndText) {
  421.         super.setSummaryObjectEndText(summaryObjectEndText);
  422.     }

  423.     /**
  424.      * Sets the start text to output when an {@link Object} is
  425.      * output in summary mode.
  426.      *
  427.      * <p>This is output before the size value.</p>
  428.      *
  429.      * <p>{@code null} is accepted, but will be converted to
  430.      * an empty String.</p>
  431.      *
  432.      * @param summaryObjectStartText  the new start of summary text
  433.      */
  434.     @Override
  435.     public void setSummaryObjectStartText(final String summaryObjectStartText) {
  436.         super.setSummaryObjectStartText(summaryObjectStartText);
  437.     }

  438.     /**
  439.      * Sets whether to use the class name.
  440.      *
  441.      * @param useClassName  the new useClassName flag
  442.      */
  443.     @Override
  444.     public void setUseClassName(final boolean useClassName) {
  445.         super.setUseClassName(useClassName);
  446.     }

  447.     /**
  448.      * Sets whether to use the field names passed in.
  449.      *
  450.      * @param useFieldNames  the new useFieldNames flag
  451.      */
  452.     @Override
  453.     public void setUseFieldNames(final boolean useFieldNames) {
  454.         super.setUseFieldNames(useFieldNames);
  455.     }

  456.     /**
  457.      * Sets whether to use the identity hash code.
  458.      *
  459.      * @param useIdentityHashCode  the new useIdentityHashCode flag
  460.      */
  461.     @Override
  462.     public void setUseIdentityHashCode(final boolean useIdentityHashCode) {
  463.         super.setUseIdentityHashCode(useIdentityHashCode);
  464.     }

  465.     /**
  466.      * Sets whether to output short or long class names.
  467.      *
  468.      * @param useShortClassName  the new useShortClassName flag
  469.      * @since 2.0
  470.      */
  471.     @Override
  472.     public void setUseShortClassName(final boolean useShortClassName) {
  473.         super.setUseShortClassName(useShortClassName);
  474.     }

  475. }