001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.commons.lang3.builder;
018
019import java.lang.reflect.Array;
020import java.util.Collection;
021import java.util.Map;
022
023/**
024 * Works with {@link ToStringBuilder} to create a {@code toString}.
025 *
026 * <p>This class is intended to be used as a singleton.
027 * There is no need to instantiate a new style each time.
028 * Simply instantiate the class once, customize the values as required, and
029 * store the result in a public static final variable for the rest of the
030 * program to access.</p>
031 *
032 * @since 1.0
033 */
034public class StandardToStringStyle extends ToStringStyle {
035
036    /**
037     * Required for serialization support.
038     *
039     * @see java.io.Serializable
040     */
041    private static final long serialVersionUID = 1L;
042
043    /**
044     * Constructor.
045     */
046    public StandardToStringStyle() {
047    }
048
049    /**
050     * Gets whether to use the class name.
051     *
052     * @return the current useClassName flag
053     */
054    @Override
055    public boolean isUseClassName() {
056        return super.isUseClassName();
057    }
058
059    /**
060     * Sets whether to use the class name.
061     *
062     * @param useClassName  the new useClassName flag
063     */
064    @Override
065    public void setUseClassName(final boolean useClassName) {
066        super.setUseClassName(useClassName);
067    }
068
069    /**
070     * Gets whether to output short or long class names.
071     *
072     * @return the current useShortClassName flag
073     * @since 2.0
074     */
075    @Override
076    public boolean isUseShortClassName() {
077        return super.isUseShortClassName();
078    }
079
080    /**
081     * Sets whether to output short or long class names.
082     *
083     * @param useShortClassName  the new useShortClassName flag
084     * @since 2.0
085     */
086    @Override
087    public void setUseShortClassName(final boolean useShortClassName) {
088        super.setUseShortClassName(useShortClassName);
089    }
090
091    /**
092     * Gets whether to use the identity hash code.
093     * @return the current useIdentityHashCode flag
094     */
095    @Override
096    public boolean isUseIdentityHashCode() {
097        return super.isUseIdentityHashCode();
098    }
099
100    /**
101     * Sets whether to use the identity hash code.
102     *
103     * @param useIdentityHashCode  the new useIdentityHashCode flag
104     */
105    @Override
106    public void setUseIdentityHashCode(final boolean useIdentityHashCode) {
107        super.setUseIdentityHashCode(useIdentityHashCode);
108    }
109
110    /**
111     * Gets whether to use the field names passed in.
112     *
113     * @return the current useFieldNames flag
114     */
115    @Override
116    public boolean isUseFieldNames() {
117        return super.isUseFieldNames();
118    }
119
120    /**
121     * Sets whether to use the field names passed in.
122     *
123     * @param useFieldNames  the new useFieldNames flag
124     */
125    @Override
126    public void setUseFieldNames(final boolean useFieldNames) {
127        super.setUseFieldNames(useFieldNames);
128    }
129
130    /**
131     * Gets whether to use full detail when the caller doesn't
132     * specify.
133     *
134     * @return the current defaultFullDetail flag
135     */
136    @Override
137    public boolean isDefaultFullDetail() {
138        return super.isDefaultFullDetail();
139    }
140
141    /**
142     * Sets whether to use full detail when the caller doesn't
143     * specify.
144     *
145     * @param defaultFullDetail  the new defaultFullDetail flag
146     */
147    @Override
148    public void setDefaultFullDetail(final boolean defaultFullDetail) {
149        super.setDefaultFullDetail(defaultFullDetail);
150    }
151
152    /**
153     * Gets whether to output array content detail.
154     *
155     * @return the current array content detail setting
156     */
157    @Override
158    public boolean isArrayContentDetail() {
159        return super.isArrayContentDetail();
160    }
161
162    /**
163     * Sets whether to output array content detail.
164     *
165     * @param arrayContentDetail  the new arrayContentDetail flag
166     */
167    @Override
168    public void setArrayContentDetail(final boolean arrayContentDetail) {
169        super.setArrayContentDetail(arrayContentDetail);
170    }
171
172    /**
173     * Gets the array start text.
174     *
175     * @return the current array start text
176     */
177    @Override
178    public String getArrayStart() {
179        return super.getArrayStart();
180    }
181
182    /**
183     * Sets the array start text.
184     *
185     * <p>{@code null} is accepted, but will be converted
186     * to an empty String.</p>
187     *
188     * @param arrayStart  the new array start text
189     */
190    @Override
191    public void setArrayStart(final String arrayStart) {
192        super.setArrayStart(arrayStart);
193    }
194
195    /**
196     * Gets the array end text.
197     *
198     * @return the current array end text
199     */
200    @Override
201    public String getArrayEnd() {
202        return super.getArrayEnd();
203    }
204
205    /**
206     * Sets the array end text.
207     *
208     * <p>{@code null} is accepted, but will be converted
209     * to an empty String.</p>
210     *
211     * @param arrayEnd  the new array end text
212     */
213    @Override
214    public void setArrayEnd(final String arrayEnd) {
215        super.setArrayEnd(arrayEnd);
216    }
217
218    /**
219     * Gets the array separator text.
220     *
221     * @return the current array separator text
222     */
223    @Override
224    public String getArraySeparator() {
225        return super.getArraySeparator();
226    }
227
228    /**
229     * Sets the array separator text.
230     *
231     * <p>{@code null} is accepted, but will be converted
232     * to an empty String.</p>
233     *
234     * @param arraySeparator  the new array separator text
235     */
236    @Override
237    public void setArraySeparator(final String arraySeparator) {
238        super.setArraySeparator(arraySeparator);
239    }
240
241    /**
242     * Gets the content start text.
243     *
244     * @return the current content start text
245     */
246    @Override
247    public String getContentStart() {
248        return super.getContentStart();
249    }
250
251    /**
252     * Sets the content start text.
253     *
254     * <p>{@code null} is accepted, but will be converted
255     * to an empty String.</p>
256     *
257     * @param contentStart  the new content start text
258     */
259    @Override
260    public void setContentStart(final String contentStart) {
261        super.setContentStart(contentStart);
262    }
263
264    /**
265     * Gets the content end text.
266     *
267     * @return the current content end text
268     */
269    @Override
270    public String getContentEnd() {
271        return super.getContentEnd();
272    }
273
274    /**
275     * Sets the content end text.
276     *
277     * <p>{@code null} is accepted, but will be converted
278     * to an empty String.</p>
279     *
280     * @param contentEnd  the new content end text
281     */
282    @Override
283    public void setContentEnd(final String contentEnd) {
284        super.setContentEnd(contentEnd);
285    }
286
287    /**
288     * Gets the field name value separator text.
289     *
290     * @return the current field name value separator text
291     */
292    @Override
293    public String getFieldNameValueSeparator() {
294        return super.getFieldNameValueSeparator();
295    }
296
297    /**
298     * Sets the field name value separator text.
299     *
300     * <p>{@code null} is accepted, but will be converted
301     * to an empty String.</p>
302     *
303     * @param fieldNameValueSeparator  the new field name value separator text
304     */
305    @Override
306    public void setFieldNameValueSeparator(final String fieldNameValueSeparator) {
307        super.setFieldNameValueSeparator(fieldNameValueSeparator);
308    }
309
310    /**
311     * Gets the field separator text.
312     *
313     * @return the current field separator text
314     */
315    @Override
316    public String getFieldSeparator() {
317        return super.getFieldSeparator();
318    }
319
320    /**
321     * Sets the field separator text.
322     *
323     * <p>{@code null} is accepted, but will be converted
324     * to an empty String.</p>
325     *
326     * @param fieldSeparator  the new field separator text
327     */
328    @Override
329    public void setFieldSeparator(final String fieldSeparator) {
330        super.setFieldSeparator(fieldSeparator);
331    }
332
333    /**
334     * Gets whether the field separator should be added at the start
335     * of each buffer.
336     *
337     * @return the fieldSeparatorAtStart flag
338     * @since 2.0
339     */
340    @Override
341    public boolean isFieldSeparatorAtStart() {
342        return super.isFieldSeparatorAtStart();
343    }
344
345    /**
346     * Sets whether the field separator should be added at the start
347     * of each buffer.
348     *
349     * @param fieldSeparatorAtStart  the fieldSeparatorAtStart flag
350     * @since 2.0
351     */
352    @Override
353    public void setFieldSeparatorAtStart(final boolean fieldSeparatorAtStart) {
354        super.setFieldSeparatorAtStart(fieldSeparatorAtStart);
355    }
356
357    /**
358     * Gets whether the field separator should be added at the end
359     * of each buffer.
360     *
361     * @return fieldSeparatorAtEnd flag
362     * @since 2.0
363     */
364    @Override
365    public boolean isFieldSeparatorAtEnd() {
366        return super.isFieldSeparatorAtEnd();
367    }
368
369    /**
370     * Sets whether the field separator should be added at the end
371     * of each buffer.
372     *
373     * @param fieldSeparatorAtEnd  the fieldSeparatorAtEnd flag
374     * @since 2.0
375     */
376    @Override
377    public void setFieldSeparatorAtEnd(final boolean fieldSeparatorAtEnd) {
378        super.setFieldSeparatorAtEnd(fieldSeparatorAtEnd);
379    }
380
381    /**
382     * Gets the text to output when {@code null} found.
383     *
384     * @return the current text to output when {@code null} found
385     */
386    @Override
387    public String getNullText() {
388        return super.getNullText();
389    }
390
391    /**
392     * Sets the text to output when {@code null} found.
393     *
394     * <p>{@code null} is accepted, but will be converted
395     * to an empty String.</p>
396     *
397     * @param nullText  the new text to output when {@code null} found
398     */
399    @Override
400    public void setNullText(final String nullText) {
401        super.setNullText(nullText);
402    }
403
404    /**
405     * Gets the text to output when a {@link Collection},
406     * {@link Map} or {@link Array} size is output.
407     *
408     * <p>This is output before the size value.</p>
409     *
410     * @return the current start of size text
411     */
412    @Override
413    public String getSizeStartText() {
414        return super.getSizeStartText();
415    }
416
417    /**
418     * Sets the start text to output when a {@link Collection},
419     * {@link Map} or {@link Array} size is output.
420     *
421     * <p>This is output before the size value.</p>
422     *
423     * <p>{@code null} is accepted, but will be converted to
424     * an empty String.</p>
425     *
426     * @param sizeStartText  the new start of size text
427     */
428    @Override
429    public void setSizeStartText(final String sizeStartText) {
430        super.setSizeStartText(sizeStartText);
431    }
432
433    /**
434     * Gets the end text to output when a {@link Collection},
435     * {@link Map} or {@link Array} size is output.
436     *
437     * <p>This is output after the size value.</p>
438     *
439     * @return the current end of size text
440     */
441    @Override
442    public String getSizeEndText() {
443        return super.getSizeEndText();
444    }
445
446    /**
447     * Sets the end text to output when a {@link Collection},
448     * {@link Map} or {@link Array} size is output.
449     *
450     * <p>This is output after the size value.</p>
451     *
452     * <p>{@code null} is accepted, but will be converted
453     * to an empty String.</p>
454     *
455     * @param sizeEndText  the new end of size text
456     */
457    @Override
458    public void setSizeEndText(final String sizeEndText) {
459        super.setSizeEndText(sizeEndText);
460    }
461
462    /**
463     * Gets the start text to output when an {@link Object} is
464     * output in summary mode.
465     *
466     * <p>This is output before the size value.</p>
467     *
468     * @return the current start of summary text
469     */
470    @Override
471    public String getSummaryObjectStartText() {
472        return super.getSummaryObjectStartText();
473    }
474
475    /**
476     * Sets the start text to output when an {@link Object} is
477     * output in summary mode.
478     *
479     * <p>This is output before the size value.</p>
480     *
481     * <p>{@code null} is accepted, but will be converted to
482     * an empty String.</p>
483     *
484     * @param summaryObjectStartText  the new start of summary text
485     */
486    @Override
487    public void setSummaryObjectStartText(final String summaryObjectStartText) {
488        super.setSummaryObjectStartText(summaryObjectStartText);
489    }
490
491    /**
492     * Gets the end text to output when an {@link Object} is
493     * output in summary mode.
494     *
495     * <p>This is output after the size value.</p>
496     *
497     * @return the current end of summary text
498     */
499    @Override
500    public String getSummaryObjectEndText() {
501        return super.getSummaryObjectEndText();
502    }
503
504    /**
505     * Sets the end text to output when an {@link Object} is
506     * output in summary mode.
507     *
508     * <p>This is output after the size value.</p>
509     *
510     * <p>{@code null} is accepted, but will be converted to
511     * an empty String.</p>
512     *
513     * @param summaryObjectEndText  the new end of summary text
514     */
515    @Override
516    public void setSummaryObjectEndText(final String summaryObjectEndText) {
517        super.setSummaryObjectEndText(summaryObjectEndText);
518    }
519
520}