Multiple Mixins in one class?

402 views
Skip to first unread message

Ygor Castor

unread,
Oct 9, 2018, 8:13:09 PM10/9/18
to jackson-user
Hello, i'm having a problem with a scenario, i've created the following Mixin that is responsible to append a property in every object passed through the object mapper:

@JsonAppend(
    prepend = true,
    props = {
        @JsonAppend.Prop(name = "_expandables", value = ExpandableProperty.class)
})
public interface ExpandableMixin {
}

But now, i need to add another mixin to the object mapper, is there a way to do that? I've already tried to create an interface that extends both mixins, but sadly it did not worked, if it's not possible, is there another way to achieve the same result?  

Tatu Saloranta

unread,
Oct 10, 2018, 9:14:36 PM10/10/18
to jackson-user
Your attempt to use a subtype should work, and that is the only way to
get mix-in annotations from multiple class declarations.
There is no way to register multiple mix-in classes and underlying
resolver does not have means to support that either, so it is
unlikely that support would be added.

But I would be interested in helping sub-class approach work: mix-in
types` class hierarchy is introspected and used, not just
the mix-in class but its parent-classes/-interfaces.

-+ Tatu +-
Reply all
Reply to author
Forward
0 new messages