Closed mattrpav closed 9 months ago
+1
I see there is a SimpleToStringPlugin
, but it was disabled by the author at some point.
@highsource Can it be enabled again please? Or is it somehow broken?
@andrei-ivanov There's nothing to enable, it was never implemented. The class is a copy-paste of ToStringPlugin
.
The problem with simple toString
plugin is that it is very cumbersome to implement it in a non-strategic way. Basically I'd have to generate all the "to string" code contained in the strategies into the schema-derived classes. And "to string" strategies are ca. 3-4x larger than, say, the hash code strategy.
At the same time I don't quite understand what is the problem with an additional runtime dependency. I mean, OK, it is better without the runtime dep, but for the price of ugly code in the toString
method? I really don't know.
I was thinking the deep-as-possible is probably the wrong approach. A shallow inspection of only immediate member primitive and boxes primitives fields would cover a large number of use cases and allow for a depedency-free model jar. Scenarios that need more than first-level could then opt for the toString strategy and the runtime dependency.
Ie only “to string” member fields of these types:
String int / Integer short / Short long / Long double / double float / Float boolean / Boolean etc
@mattrpav This would be much easier but to be honest this is very limited. Would not even cover collections or JAXBElement<T>
.
But I'll think about it.
@highsource gotcha. Perhaps, for collections a suitable solution for class:
public class MyFoo { private List<?> items... }
The toString on the collection could be:
items != null ? "items: [" + items.size() + "]" : "items: [null]"
I'm fine w/ no support for JAXBElement
Follow up issue : https://github.com/highsource/jaxb-tools/issues/433
Closing in favor of follow up issue in jaxb-tools
The goal would be to have a deep (as possible), reflection-free, runtime-free option similar to the SimpleEquals and SimpleHashcode for toString method creation.