public class MultilineRecursiveToStringStyle extends RecursiveToStringStyle
Works with ToStringBuilder
to create a "deep" toString
.
But instead a single line like the RecursiveToStringStyle
this creates a multiline String
similar to the ToStringStyle.MULTI_LINE_STYLE
.
To use this class write code as follows:
public class Job { String title; ... } public class Person { String name; int age; boolean smoker; Job job; ... public String toString() { return new ReflectionToStringBuilder(this, new MultilineRecursiveToStringStyle()).toString(); } }
This will produce a toString of the format:
Person@7f54[
name=Stephen,
age=29,
smoker=false,
job=Job@43cd2[
title=Manager
]
]
DEFAULT_STYLE, JSON_STYLE, MULTI_LINE_STYLE, NO_CLASS_NAME_STYLE, NO_FIELD_NAMES_STYLE, SHORT_PREFIX_STYLE, SIMPLE_STYLE
Constructor and Description |
---|
MultilineRecursiveToStringStyle()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
appendDetail(java.lang.StringBuffer buffer,
java.lang.String fieldName,
java.lang.Object value)
Append to the
toString an Object
value, printing the full detail of the Object . |
public MultilineRecursiveToStringStyle()
public void appendDetail(java.lang.StringBuffer buffer, java.lang.String fieldName, java.lang.Object value)
ToStringStyle
Append to the toString
an Object
value, printing the full detail of the Object
.
appendDetail
in class RecursiveToStringStyle
buffer
- the StringBuffer
to populatefieldName
- the field name, typically not used as already appendedvalue
- the value to add to the toString
,
not null
Copyright © 2010 - 2020 Adobe. All Rights Reserved