I am trying to map one object type to another using ModelMapper. I have defined the following mapping in my PropertyMap implementation:
map().getExtended().setIncludeMaskType(MaskType.fromValue(source.getExtendedPollingType().getMaskSettings().getIncludeMask().getMaskType()));
The problem is that the source type method call source.getExtendedPollingType().getMaskSettings().getIncludeMask().getMaskType()
returns String while the destination type accepts a MaskType
enum
Therefore I am using MaskType.fromValue()
to convert the String to enum.
The problem is that value of fails with Caused by: java.lang.IllegalArgumentException
since this is source method call basically returns null during configuration.
So how should I handle this use case?