4 ms·
We use lombok, and the toString annotation is immensely helpful for logging and avoiding this type of thing.
by flerchin 7y ago
We use lombok, and the toString annotation is immensely helpful for logging and avoiding this type of thing.
- fahadkhan 7y agoHow does Lombok help to avoid this?
- nsporillo 7y agoLomboks annotation @ToString will automatically generate the typical overridden toString() method based on the fields.
- chopin 7y agoEven Object.toString could do this using reflection. If you're worried about the performance, override it. I never understood why this is not the case (doesn't Haskell do something similar?).
- chopin 7y agoI just tried this in Java and I ran quickly into circularity issues (one of the fields has an indirect reference to the same object, say a list which the current instance is part of). How does Lombok cope with that? It's not that easy as I thought (see my sibling comment).