Skip to content

Issue generating nested interface object #320

Closed Answered by CarstenWickner
patpatpat123 asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @patpatpat123,

Thank you for the kind praise. 😄

On the matter of handling subtypes, there are a couple of ways to go about it.

Main Options

Target Type Override

If you want to explicitly replace the Animal interface with a single subtype and effectively hide the fact that in your code it is declared just as Animal, then you can use a "Target Type Override".

configBuilder.forFields()
    .withTargetTypeOverridesResolver(field -> field.getType().getErasedType() == Animal.class
            ? List.of(field.getContext().resolve(Cow.class)) : null);

Subtype Resolver

You can configure a "Subtype Resolver", which identifies all the subtypes of a given interface/superclass.
As it so happens, th…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by CarstenWickner
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #318 on March 06, 2023 20:20.