ModelMapper skip a field codegrepper
UserEntity user =new UserEntity();
ModelMapper modelMapper = new ModelMapper();
modelMapper.getConfiguration().setAmbiguityIgnored(true);
PropertyMap<UserDTO,UserEntity > clientPropertyMap= new PropertyMap<UserDTO,UserEntity>() {
@Override
protected void configure() {
skip(destination.getFatherDetailsEntity().getUser());
skip(destination.getFirstName());
}
};
modelMapper.addMappings(clientPropertyMap);
modelMapper.map(request, user);
OUTPUT: UserEntity{userId=0, firstName='null', lastName='Ahsan', userName='ArslanAhsan2', creationTime=null, fatherDetailsEntity=FatherDetailsEntity{id=null, fatherName='ABCD', cnic='38201'}}