Created
September 29, 2015 20:00
-
-
Save vic/acc0dc0938978da46e70 to your computer and use it in GitHub Desktop.
Mapping a collection of interfaces
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Target { | |
List<TargetItem> items; | |
} | |
interface TargetItem {} | |
class TargetItemA implements TargetItem {} | |
class TargetItemB implements TargetItem {} | |
class Source { | |
List<SourceItem> items; | |
} | |
interface SourceItem {} | |
class SourceItemA implements SourceItem {} | |
class SourceItemB implements SourceItem {} | |
@Mapper | |
interface MyMapper { | |
public Target sourceToTarget(Source source); | |
// how to map a collection with polymophic items | |
public List<TargetItem> itemsToTarget(List<SourceItem> items); | |
public TargetItemA itemAToTarget(SourceItemA item); | |
public TargetItemB itemBToTarget(SourceItemB item); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment