View Javadoc
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  
19  /**
20   * <p>Works with {@link ToStringBuilder} to create a {@code toString}.</p>
21   *
22   * <p>This class is intended to be used as a singleton.
23   * There is no need to instantiate a new style each time.
24   * Simply instantiate the class once, customize the values as required, and
25   * store the result in a public static final variable for the rest of the
26   * program to access.</p>
27   *
28   * @since 1.0
29   */
30  public class StandardToStringStyle extends ToStringStyle {
31  
32      /**
33       * Required for serialization support.
34       *
35       * @see java.io.Serializable
36       */
37      private static final long serialVersionUID = 1L;
38  
39      /**
40       * <p>Constructor.</p>
41       */
42      public StandardToStringStyle() {
43      }
44  
45      //---------------------------------------------------------------------
46  
47      /**
48       * <p>Gets whether to use the class name.</p>
49       *
50       * @return the current useClassName flag
51       */
52      @Override
53      public boolean isUseClassName() { // NOPMD as this is implementing the abstract class
54          return super.isUseClassName();
55      }
56  
57      /**
58       * <p>Sets whether to use the class name.</p>
59       *
60       * @param useClassName  the new useClassName flag
61       */
62      @Override
63      public void setUseClassName(final boolean useClassName) { // NOPMD as this is implementing the abstract class
64          super.setUseClassName(useClassName);
65      }
66  
67      //---------------------------------------------------------------------
68  
69      /**
70       * <p>Gets whether to output short or long class names.</p>
71       *
72       * @return the current useShortClassName flag
73       * @since 2.0
74       */
75      @Override
76      public boolean isUseShortClassName() { // NOPMD as this is implementing the abstract class
77          return super.isUseShortClassName();
78      }
79  
80      /**
81       * <p>Sets whether to output short or long class names.</p>
82       *
83       * @param useShortClassName  the new useShortClassName flag
84       * @since 2.0
85       */
86      @Override
87      public void setUseShortClassName(final boolean useShortClassName) { // NOPMD as this is implementing the abstract class
88          super.setUseShortClassName(useShortClassName);
89      }
90  
91      //---------------------------------------------------------------------
92  
93      /**
94       * <p>Gets whether to use the identity hash code.</p>
95       * @return the current useIdentityHashCode flag
96       */
97      @Override
98      public boolean isUseIdentityHashCode() { // NOPMD as this is implementing the abstract class
99          return super.isUseIdentityHashCode();
100     }
101 
102     /**
103      * <p>Sets whether to use the identity hash code.</p>
104      *
105      * @param useIdentityHashCode  the new useIdentityHashCode flag
106      */
107     @Override
108     public void setUseIdentityHashCode(final boolean useIdentityHashCode) { // NOPMD as this is implementing the abstract class
109         super.setUseIdentityHashCode(useIdentityHashCode);
110     }
111 
112     //---------------------------------------------------------------------
113 
114     /**
115      * <p>Gets whether to use the field names passed in.</p>
116      *
117      * @return the current useFieldNames flag
118      */
119     @Override
120     public boolean isUseFieldNames() { // NOPMD as this is implementing the abstract class
121         return super.isUseFieldNames();
122     }
123 
124     /**
125      * <p>Sets whether to use the field names passed in.</p>
126      *
127      * @param useFieldNames  the new useFieldNames flag
128      */
129     @Override
130     public void setUseFieldNames(final boolean useFieldNames) { // NOPMD as this is implementing the abstract class
131         super.setUseFieldNames(useFieldNames);
132     }
133 
134     //---------------------------------------------------------------------
135 
136     /**
137      * <p>Gets whether to use full detail when the caller doesn't
138      * specify.</p>
139      *
140      * @return the current defaultFullDetail flag
141      */
142     @Override
143     public boolean isDefaultFullDetail() { // NOPMD as this is implementing the abstract class
144         return super.isDefaultFullDetail();
145     }
146 
147     /**
148      * <p>Sets whether to use full detail when the caller doesn't
149      * specify.</p>
150      *
151      * @param defaultFullDetail  the new defaultFullDetail flag
152      */
153     @Override
154     public void setDefaultFullDetail(final boolean defaultFullDetail) { // NOPMD as this is implementing the abstract class
155         super.setDefaultFullDetail(defaultFullDetail);
156     }
157 
158     //---------------------------------------------------------------------
159 
160     /**
161      * <p>Gets whether to output array content detail.</p>
162      *
163      * @return the current array content detail setting
164      */
165     @Override
166     public boolean isArrayContentDetail() { // NOPMD as this is implementing the abstract class
167         return super.isArrayContentDetail();
168     }
169 
170     /**
171      * <p>Sets whether to output array content detail.</p>
172      *
173      * @param arrayContentDetail  the new arrayContentDetail flag
174      */
175     @Override
176     public void setArrayContentDetail(final boolean arrayContentDetail) { // NOPMD as this is implementing the abstract class
177         super.setArrayContentDetail(arrayContentDetail);
178     }
179 
180     //---------------------------------------------------------------------
181 
182     /**
183      * <p>Gets the array start text.</p>
184      *
185      * @return the current array start text
186      */
187     @Override
188     public String getArrayStart() { // NOPMD as this is implementing the abstract class
189         return super.getArrayStart();
190     }
191 
192     /**
193      * <p>Sets the array start text.</p>
194      *
195      * <p>{@code null} is accepted, but will be converted
196      * to an empty String.</p>
197      *
198      * @param arrayStart  the new array start text
199      */
200     @Override
201     public void setArrayStart(final String arrayStart) { // NOPMD as this is implementing the abstract class
202         super.setArrayStart(arrayStart);
203     }
204 
205     //---------------------------------------------------------------------
206 
207     /**
208      * <p>Gets the array end text.</p>
209      *
210      * @return the current array end text
211      */
212     @Override
213     public String getArrayEnd() { // NOPMD as this is implementing the abstract class
214         return super.getArrayEnd();
215     }
216 
217     /**
218      * <p>Sets the array end text.</p>
219      *
220      * <p>{@code null} is accepted, but will be converted
221      * to an empty String.</p>
222      *
223      * @param arrayEnd  the new array end text
224      */
225     @Override
226     public void setArrayEnd(final String arrayEnd) { // NOPMD as this is implementing the abstract class
227         super.setArrayEnd(arrayEnd);
228     }
229 
230     //---------------------------------------------------------------------
231 
232     /**
233      * <p>Gets the array separator text.</p>
234      *
235      * @return the current array separator text
236      */
237     @Override
238     public String getArraySeparator() { // NOPMD as this is implementing the abstract class
239         return super.getArraySeparator();
240     }
241 
242     /**
243      * <p>Sets the array separator text.</p>
244      *
245      * <p>{@code null} is accepted, but will be converted
246      * to an empty String.</p>
247      *
248      * @param arraySeparator  the new array separator text
249      */
250     @Override
251     public void setArraySeparator(final String arraySeparator) { // NOPMD as this is implementing the abstract class
252         super.setArraySeparator(arraySeparator);
253     }
254 
255     //---------------------------------------------------------------------
256 
257     /**
258      * <p>Gets the content start text.</p>
259      *
260      * @return the current content start text
261      */
262     @Override
263     public String getContentStart() { // NOPMD as this is implementing the abstract class
264         return super.getContentStart();
265     }
266 
267     /**
268      * <p>Sets the content start text.</p>
269      *
270      * <p>{@code null} is accepted, but will be converted
271      * to an empty String.</p>
272      *
273      * @param contentStart  the new content start text
274      */
275     @Override
276     public void setContentStart(final String contentStart) { // NOPMD as this is implementing the abstract class
277         super.setContentStart(contentStart);
278     }
279 
280     //---------------------------------------------------------------------
281 
282     /**
283      * <p>Gets the content end text.</p>
284      *
285      * @return the current content end text
286      */
287     @Override
288     public String getContentEnd() { // NOPMD as this is implementing the abstract class
289         return super.getContentEnd();
290     }
291 
292     /**
293      * <p>Sets the content end text.</p>
294      *
295      * <p>{@code null} is accepted, but will be converted
296      * to an empty String.</p>
297      *
298      * @param contentEnd  the new content end text
299      */
300     @Override
301     public void setContentEnd(final String contentEnd) { // NOPMD as this is implementing the abstract class
302         super.setContentEnd(contentEnd);
303     }
304 
305     //---------------------------------------------------------------------
306 
307     /**
308      * <p>Gets the field name value separator text.</p>
309      *
310      * @return the current field name value separator text
311      */
312     @Override
313     public String getFieldNameValueSeparator() { // NOPMD as this is implementing the abstract class
314         return super.getFieldNameValueSeparator();
315     }
316 
317     /**
318      * <p>Sets the field name value separator text.</p>
319      *
320      * <p>{@code null} is accepted, but will be converted
321      * to an empty String.</p>
322      *
323      * @param fieldNameValueSeparator  the new field name value separator text
324      */
325     @Override
326     public void setFieldNameValueSeparator(final String fieldNameValueSeparator) { // NOPMD as this is implementing the abstract class
327         super.setFieldNameValueSeparator(fieldNameValueSeparator);
328     }
329 
330     //---------------------------------------------------------------------
331 
332     /**
333      * <p>Gets the field separator text.</p>
334      *
335      * @return the current field separator text
336      */
337     @Override
338     public String getFieldSeparator() { // NOPMD as this is implementing the abstract class
339         return super.getFieldSeparator();
340     }
341 
342     /**
343      * <p>Sets the field separator text.</p>
344      *
345      * <p>{@code null} is accepted, but will be converted
346      * to an empty String.</p>
347      *
348      * @param fieldSeparator  the new field separator text
349      */
350     @Override
351     public void setFieldSeparator(final String fieldSeparator) { // NOPMD as this is implementing the abstract class
352         super.setFieldSeparator(fieldSeparator);
353     }
354 
355     //---------------------------------------------------------------------
356 
357     /**
358      * <p>Gets whether the field separator should be added at the start
359      * of each buffer.</p>
360      *
361      * @return the fieldSeparatorAtStart flag
362      * @since 2.0
363      */
364     @Override
365     public boolean isFieldSeparatorAtStart() { // NOPMD as this is implementing the abstract class
366         return super.isFieldSeparatorAtStart();
367     }
368 
369     /**
370      * <p>Sets whether the field separator should be added at the start
371      * of each buffer.</p>
372      *
373      * @param fieldSeparatorAtStart  the fieldSeparatorAtStart flag
374      * @since 2.0
375      */
376     @Override
377     public void setFieldSeparatorAtStart(final boolean fieldSeparatorAtStart) { // NOPMD as this is implementing the abstract class
378         super.setFieldSeparatorAtStart(fieldSeparatorAtStart);
379     }
380 
381     //---------------------------------------------------------------------
382 
383     /**
384      * <p>Gets whether the field separator should be added at the end
385      * of each buffer.</p>
386      *
387      * @return fieldSeparatorAtEnd flag
388      * @since 2.0
389      */
390     @Override
391     public boolean isFieldSeparatorAtEnd() { // NOPMD as this is implementing the abstract class
392         return super.isFieldSeparatorAtEnd();
393     }
394 
395     /**
396      * <p>Sets whether the field separator should be added at the end
397      * of each buffer.</p>
398      *
399      * @param fieldSeparatorAtEnd  the fieldSeparatorAtEnd flag
400      * @since 2.0
401      */
402     @Override
403     public void setFieldSeparatorAtEnd(final boolean fieldSeparatorAtEnd) { // NOPMD as this is implementing the abstract class
404         super.setFieldSeparatorAtEnd(fieldSeparatorAtEnd);
405     }
406 
407     //---------------------------------------------------------------------
408 
409     /**
410      * <p>Gets the text to output when {@code null} found.</p>
411      *
412      * @return the current text to output when {@code null} found
413      */
414     @Override
415     public String getNullText() { // NOPMD as this is implementing the abstract class
416         return super.getNullText();
417     }
418 
419     /**
420      * <p>Sets the text to output when {@code null} found.</p>
421      *
422      * <p>{@code null} is accepted, but will be converted
423      * to an empty String.</p>
424      *
425      * @param nullText  the new text to output when {@code null} found
426      */
427     @Override
428     public void setNullText(final String nullText) { // NOPMD as this is implementing the abstract class
429         super.setNullText(nullText);
430     }
431 
432     //---------------------------------------------------------------------
433 
434     /**
435      * <p>Gets the text to output when a {@code Collection},
436      * {@code Map} or {@code Array} size is output.</p>
437      *
438      * <p>This is output before the size value.</p>
439      *
440      * @return the current start of size text
441      */
442     @Override
443     public String getSizeStartText() { // NOPMD as this is implementing the abstract class
444         return super.getSizeStartText();
445     }
446 
447     /**
448      * <p>Sets the start text to output when a {@code Collection},
449      * {@code Map} or {@code Array} size is output.</p>
450      *
451      * <p>This is output before the size value.</p>
452      *
453      * <p>{@code null} is accepted, but will be converted to
454      * an empty String.</p>
455      *
456      * @param sizeStartText  the new start of size text
457      */
458     @Override
459     public void setSizeStartText(final String sizeStartText) { // NOPMD as this is implementing the abstract class
460         super.setSizeStartText(sizeStartText);
461     }
462 
463     //---------------------------------------------------------------------
464 
465     /**
466      * <p>Gets the end text to output when a {@code Collection},
467      * {@code Map} or {@code Array} size is output.</p>
468      *
469      * <p>This is output after the size value.</p>
470      *
471      * @return the current end of size text
472      */
473     @Override
474     public String getSizeEndText() { // NOPMD as this is implementing the abstract class
475         return super.getSizeEndText();
476     }
477 
478     /**
479      * <p>Sets the end text to output when a {@code Collection},
480      * {@code Map} or {@code Array} size is output.</p>
481      *
482      * <p>This is output after the size value.</p>
483      *
484      * <p>{@code null} is accepted, but will be converted
485      * to an empty String.</p>
486      *
487      * @param sizeEndText  the new end of size text
488      */
489     @Override
490     public void setSizeEndText(final String sizeEndText) { // NOPMD as this is implementing the abstract class
491         super.setSizeEndText(sizeEndText);
492     }
493 
494     //---------------------------------------------------------------------
495 
496     /**
497      * <p>Gets the start text to output when an {@code Object} is
498      * output in summary mode.</p>
499      *
500      * <P>This is output before the size value.</p>
501      *
502      * @return the current start of summary text
503      */
504     @Override
505     public String getSummaryObjectStartText() { // NOPMD as this is implementing the abstract class
506         return super.getSummaryObjectStartText();
507     }
508 
509     /**
510      * <p>Sets the start text to output when an {@code Object} is
511      * output in summary mode.</p>
512      *
513      * <p>This is output before the size value.</p>
514      *
515      * <p>{@code null} is accepted, but will be converted to
516      * an empty String.</p>
517      *
518      * @param summaryObjectStartText  the new start of summary text
519      */
520     @Override
521     public void setSummaryObjectStartText(final String summaryObjectStartText) { // NOPMD as this is implementing the abstract class
522         super.setSummaryObjectStartText(summaryObjectStartText);
523     }
524 
525     //---------------------------------------------------------------------
526 
527     /**
528      * <p>Gets the end text to output when an {@code Object} is
529      * output in summary mode.</p>
530      *
531      * <p>This is output after the size value.</p>
532      *
533      * @return the current end of summary text
534      */
535     @Override
536     public String getSummaryObjectEndText() { // NOPMD as this is implementing the abstract class
537         return super.getSummaryObjectEndText();
538     }
539 
540     /**
541      * <p>Sets the end text to output when an {@code Object} is
542      * output in summary mode.</p>
543      *
544      * <p>This is output after the size value.</p>
545      *
546      * <p>{@code null} is accepted, but will be converted to
547      * an empty String.</p>
548      *
549      * @param summaryObjectEndText  the new end of summary text
550      */
551     @Override
552     public void setSummaryObjectEndText(final String summaryObjectEndText) { // NOPMD as this is implementing the abstract class
553         super.setSummaryObjectEndText(summaryObjectEndText);
554     }
555 
556     //---------------------------------------------------------------------
557 
558 }