Mapping abstract fields.

462 views
Skip to first unread message

Ishan Bansal

unread,
Nov 16, 2015, 12:26:00 PM11/16/15
to mapstruct-users
If my source and destination classes have an abstract field (which can have various concrete types at runtime), how do I Map them using Map-struct?

Eg.
abstract class A {}
class B extends class A {}
class C extends class A {}

abstract class ADto {}
class BDto extends class ADto {}
class CDto extends class ADto {}

class Item {
A a;
}

class ItemDTO {
ADto a;
}

How do I map item to ItemDTO?

Andreas Gudian

unread,
Nov 17, 2015, 2:12:04 PM11/17/15
to Ishan Bansal, mapstruct-users
Hi Ishan,

that's currently not supported and you'd have to declare mapping methods for your specialized types (which would be generated) and implement mapping mehtods with the abstract types to "instance-of" and delegete to the specialized methods.

But there's a feature request already in GitHub: https://github.com/mapstruct/mapstruct/issues/131 - with some remaining questions on how that could look like.

If you have any ideas on how that could look like from a users perspective or maybe want to help with the implementation, feel free to join in the discussion.

Andreas


--
You received this message because you are subscribed to the Google Groups "mapstruct-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mapstruct-use...@googlegroups.com.
To post to this group, send email to mapstru...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages