Created
April 3, 2018 10:31
-
-
Save dassiorleando/7a542625bacb823294e7a187b84e7d19 to your computer and use it in GitHub Desktop.
ObjectB class described in http://www.dassiorleando.xyz/safely-tostring-a-java-object
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ObjectA { | |
private String propA; | |
private ObjectB objectB1; | |
private ObjectB objectB2; | |
public ObjectA(String propA, ObjectB objectB1) { | |
this.propA = propA; | |
this.objectB1 = objectB1; | |
} | |
// Getters and setters | |
@Override | |
public String toString() { | |
return "ObjectA{" + | |
"propA='" + propA + '\'' + | |
", objectB1=" + Objects.toString(objectB1) + | |
", objectB2=" + Objects.toString(objectB2) + | |
'}'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment