The essence of the problem is that I have a large (several thousand) class
hierarchy without an empty constructor. Since @JsonCreator does not apply
to subclasses, I would have to add the @JsonCreator and @JacksonInject to
every subclass. The following would work:
class TestDomain {
//no empty-argument constructor
@JsonCreator
public TestDomain(@JacksonInject("constructor1") Object
consAttr1) {
//code
}
}
//subclass with identical constructor
class TestDomainSub extends TestDomain {
@JsonCreator
public TestDomain(@JacksonInject("constructor1") Object
consAttr1) {
super(consAttr1);
//code
}
}
//several thousand more subclasses, none of which are annotated
The problem is that I can't go back and add the necessary @JsonCreator and
@JacksonInject annotation to so many existing subclasses. Too much work and
unnecessary boilerplate.
If @JsonCreator had an "applyToSubclasses=true" boolean property, that
would solve the problem perfectly.
I understood the initial arguments for not applying @JsonCreator to
subclasses. However, there are common simple situations like the above
where it would be the best solution: In this case, the entire class
hierarchy has exactly the same constructor pattern, so a single definition
would suffice.
I have no need for a custom deserializer with the single exception of
needing to replace the instantiation.
Rich MacDonald
--
You received this message because you are subscribed to the Google Groups
"jackson-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/d/optout.