class A { class ADto {
int id; -> int id;
List<B> b; List<BDto> b;
} }
class B { class BDto {
int id; -> int id;
C c; CDto c;
} }
While converting A -> ADto
, I want to skip mapping of C -> CDto
.
I was under the impression the following mapper would work whenever there is conversion between B -> BDto
, which doesn't seem to be the case; so the following mapper didn't help while coverting (A -> ADto)
...
class BMap extends PropertyMap<B, BDto> {
@Override
protected void configure() {
skip(destination.getC());
}
}
What should be the way to achieve this?
In this case you could have two different options.
1) Use a ModelMapper instance with a Property Map B to BDto skiping c
The first one is use a ModelMapper instance for this special case which adding the PropertyMap skiping
c
inB -> BDto
mapping. So you must add it:2) Create a Converter and use it in A to ADto PropertyMap
The other option is using a converter, so in your case you should has a
Converter
to convertB -> BDto
and then in theA -> ADto
PropertyMap
use it:Then use the Converter in your PropertyMap: