public class ToStringBean extends Object implements Serializable
It works on all read/write properties, recursively. It support all primitive types, Strings, Collections, ToString objects and multi-dimensional arrays of any of them.
Modifier | Constructor and Description |
---|---|
protected |
ToStringBean(Class<?> beanClass)
Default constructor.
|
|
ToStringBean(Class<?> beanClass,
Object obj)
Creates a ToStringBean to be used in a delegation pattern.
|
Modifier and Type | Method and Description |
---|---|
String |
toString()
Returns the String representation of the bean given in the constructor.
|
protected ToStringBean(Class<?> beanClass)
To be used by classes extending ToStringBean only.
beanClass
- indicates the class to scan for properties, normally an interface class.public ToStringBean(Class<?> beanClass, Object obj)
For example:
public class Foo implements ToString {
public String toString(String prefix) {
ToStringBean tsb = new ToStringBean(this);
return tsb.toString(prefix);
}
public String toString() {
return toString("Foo");
}
}
beanClass
- indicates the class to scan for properties, normally an interface class.obj
- object bean to create String representation.Copyright © 2019. All rights reserved.