Last active
August 2, 2018 07:50
-
-
Save chhsiao90/b777d0468852837bac8060d5c4d7f81a to your computer and use it in GitHub Desktop.
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
public <T extends CustomParserConfig> T getConfig(Map<String,Object> configObject, Class<T> classType) { | |
ModelMapper modelMapper = new ModelMapper(); | |
modelMapper.createTypeMap(configObject, classType).addMappings(new PropertyMap<Map<String,Object>, T>() { | |
@Override | |
protected void configure() { | |
map(source("fields"), destination("fields")); | |
} | |
}).map(configObject); | |
} |
hi @irshadgit - You are right, the workaround didn't work with v2.1.0 because some other issues.
After more investigation, the workaround is not working.
For more detail:
map(source("fields"), destination("fields"))
will create a mapping Map[fields] -> CustomParserConfig[fields] (Object -> List)
and ModelMapper failed to map because it think Map.fields
is an object instead of a list.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@chhsiao90 : It gives me compile error first time near
PropertyMap<Map<String,Object>>()
sayingwrong number of type arguments
. When I replaced it as belowcompile error goes but I get another error while executing it as below.