|
| 1 | +/* |
| 2 | + * Copyright MapStruct Authors. |
| 3 | + * |
| 4 | + * Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0 |
| 5 | + */ |
| 6 | + |
| 7 | +import org.mapstruct.BeanMapping; |
| 8 | +import org.mapstruct.Mapper; |
| 9 | +import org.mapstruct.Mapping; |
| 10 | +import org.mapstruct.MappingTarget; |
| 11 | +import org.example.data.UnmappedTargetPropertiesData.Target; |
| 12 | +import org.example.data.UnmappedTargetPropertiesData.Source; |
| 13 | + |
| 14 | +@Mapper |
| 15 | +interface SingleMappingMapper { |
| 16 | + |
| 17 | + @Mapping(target = "moreTarget", source = "") |
| 18 | + @Mapping(target = "moreTarget", ignore = true) |
| 19 | + @Mapping(target = "testName", source = "name") |
| 20 | + Target map(Source source); |
| 21 | +} |
| 22 | + |
| 23 | +@Mapper |
| 24 | +interface SingleMappingMapperWithIgnoreByDefault { |
| 25 | + |
| 26 | + @Mapping(target = "testName", source = "name") |
| 27 | + @BeanMapping(ignoreByDefault = true) |
| 28 | + Target map(Source source); |
| 29 | +} |
| 30 | + |
| 31 | +@Mapper |
| 32 | +interface UpdateMapper { |
| 33 | + |
| 34 | + @Mapping(target = "testName", source = "") |
| 35 | + @Mapping(target = "testName", ignore = true) |
| 36 | + @Mapping(target = "moreTarget", source = "moreSource") |
| 37 | + void update(@MappingTarget Target target, Source source); |
| 38 | +} |
| 39 | + |
| 40 | +@Mapper |
| 41 | +interface UpdateMapperWithIgnoreByDefault { |
| 42 | + |
| 43 | + @Mapping(target = "moreTarget", source = "moreSource") |
| 44 | + @BeanMapping(ignoreByDefault = true) |
| 45 | + void update(@MappingTarget Target target, Source source); |
| 46 | +} |
0 commit comments