Last active
July 6, 2020 07:43
-
-
Save TobseF/7950ce0f15efb11a30c808a1b6506f93 to your computer and use it in GitHub Desktop.
Mapstruct AnnotationParser Example
This file contains 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 BusinessModel{ | |
String zip; | |
} | |
class UiModel{ | |
String plz; | |
} | |
public interface ModelMapping extends BridgeMapping<BusinessModel, UiModel> { | |
@Mapping(source = "zip", target = "plz") | |
UiModel modelToUiModel(BusinessModel model, @MappingTarget UiModel uiModel); | |
} | |
@Test | |
public testMappingInfo(){ | |
MapStructParser mappingInfo = new MapStructParser(); | |
mappingInfo.parseMappingInterface(ModelMapping.class); | |
assertEquals("zip", mappingInfo.mapToTargetField("plz")); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment