Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inheritance problem #86

Open
salashnik opened this issue May 17, 2024 · 0 comments
Open

inheritance problem #86

salashnik opened this issue May 17, 2024 · 0 comments

Comments

@salashnik
Copy link

salashnik commented May 17, 2024

in this example code

@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = As.PROPERTY, property = "objectType")
@JsonSubTypes({
    @JsonSubTypes.Type(value = ObjectDto.class, name = "NONE"),
    @JsonSubTypes.Type(value = Object1Dto.class, name = "OBJ1"),
    @JsonSubTypes.Type(value = Object2Dto.class, name = "OBJ2")}
)
@JSONMapper
public class ObjectDto {
....
}

@JSONMapper
public class ObjectDto1 extends ObjectDto {
....
}

@JSONMapper
public class ObjectDto2 extends ObjectDto {
....
}

generation falls, because files for ObjectDto will be generated twice (in generateSubTypesDeserializers and on generate)...

in DeserializerGenerator.generate (and SerializerGenerator.generate too)

public String generate(TypeMirror beanType) {
....
        // may be subtypes must be generated after TypeRegistry.registerDeserializer called????
        generateSubTypesDeserializers(beanType);

        TypeRegistry.addInActiveGenDeserializer(beanType);
        new AptDeserializerBuilder(packageName, beanType, filer).generate();
        TypeRegistry.registerDeserializer(
            Type.stringifyTypeWithPackage(beanType), ClassName.bestGuess(deserializerName));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant