jeudi 15 octobre 2015

How to tell if an object implements a method like toString()?

I am writing a testing library and I want to be able to handle objects that may not have been provided their own implementation of String toString().

In those cases, rather that using the useless default implementation, I'd like to use the Apache Commons-Lang ToStringBuilder instead... but would rather use an object's implementation of toString() if available.

How can I tell if an object has an implementation of toString() other than the default?





Aucun commentaire:

Enregistrer un commentaire