Package com.kosdev.kos.commons.util.misc
Class ToStringBuilder
java.lang.Object
com.kosdev.kos.commons.util.misc.ToStringBuilder
Minimal string builder used to implement toString() when the
@ToString
annotation isn't used. The output matches the Lombok's output.
Example
public class Person {
String name;
int age;
boolean rightHanded;
// . . .
public String toString() {
return new ToStringBuildr(this)
.append("name", name)
.append("age", age)
.append("rightHanded", rightHanded)
.toString();
}
}
This will produce a toString() of the format:
Person[name=Stephen, age=29, rightHanded=false]
- Since:
- 10
- Version:
- 10
-
Constructor Summary
ConstructorsConstructorDescriptionToStringBuilder(Object object) Create a new builder for the specified object. -
Method Summary
-
Constructor Details
-
ToStringBuilder
Create a new builder for the specified object. The class name of the object will be used as the first token of the string.- Parameters:
object- the object the string is for- Since:
- 10
-
-
Method Details