The Answer to Life, the Universe, and Everything

Tuesday, May 15, 2007

Commons Lang toString()

Jakarta Commons Lang support the reflection for toString() which need to synchronize with the changes made for the object model.

public String toString(){
return ReflectionToStringBuilder.toString(this);
}


For the customization of the output,
public String toString(){
return ReflectionToStringBuilder.toString(this,ToStringStyle.MULTI_LINE_STYLE)
.append("lastName",lastName).append("firstName",firstName).toString();
}

No comments: