Skip to content

Tag: polymorphism

Jackson subtypes – how to specify a default

I want to do something like this with subtypes. I have 3 different types of objects: value can either be a string or an object. The corresponding Java classes are I don’t mind having a discriminator inside Obj1 and Obj2, but there is no place for one when the value is just a string. Is there a way that …

Jackson deserialization to concrete polymorphic class

I have following Jackson annotated classes (Kotlin) I try to deserialize JSON that does not contain type property but I provide concrete class so it should not matter I get Missing type id when trying to resolve subtype of … anyway. Is there a way how to tell Jackson to use the type provided in the dese…

java polymorphism aliasing issue

If there’s 3 classes. A, B and C. class B extends A and class C extends B. class A has equals method: class B has equals method: and class C has euals method: And the main has these code lines: I can’t understand why the equals method of class A is being executed. I know that overloaded methods ar…