Link Details

Link 62339 thumbnail
User 265356 avatar

By mosheco
via j2ee-now.blogspot.com
Published: Jan 22 2008 / 03:15

In many cases it's required to implement "toString to" display the DTO (Data Transfer Object) in the log file for debugging, In this case a good solution is to use generic DTO implementaion which implement "toString" and "equal" methods in a generic way. This link contains the complete source code.
  • 6
  • 11
  • 1754
  • 587

Comments

Add your comment
User 210175 avatar

jtheory replied ago:

4 votes Vote down Vote up Reply

See org.apache.commons.lang.builder.ToStringBuilder and org.apache.commons.lang.builder.EqualsBuilder and related classes in Apache Commons lang.

Also, I know it's not quite fair to a pure content evaluation, but the poor grammar and spelling make it tough reading.

User 254602 avatar

Nick Brown replied ago:

0 votes Vote down Vote up Reply

The lack of indentation also hurts readability. And as far as I can tell, the equals() method isn't valid as its not necessarily transitive or symmetric, which means it might break any data structure that holds an object implementing it. Not to mention the possibility of an infinite recursion occurring in there...

Add your comment


Html tags not supported. Reply is editable for 5 minutes. Use [code lang="java|ruby|sql|css|xml"][/code] to post code snippets.