Hi,
I was just playing with ModelMapper and it looks pretty cool so far. Good job!
However when I try to add a custom mapping to the mapper it throws an exception.
Custom mapping:
PropertyMap<User, DUser> userMap = new PropertyMap<User, DUser>() {
@Override
protected void configure() {
map().roleCount = source.getRoles().size();
}
};
Configuring the mapping throws exception:
modelMapper.addMappings(userMap);
Exception:
Exception in thread "main" org.modelmapper.ConfigurationException: ModelMapper configuration errors:
1) A mapping is missing a required destination method.
1 error
at org.modelmapper.internal.Errors.throwConfigurationExceptionIfErrorsExist(Errors.java:226)
at org.modelmapper.internal.MappingBuilderImpl.build(MappingBuilderImpl.java:137)
at org.modelmapper.internal.TypeMapImpl.addMappings(TypeMapImpl.java:71)
at org.modelmapper.internal.TypeMapStore.getOrCreate(TypeMapStore.java:93)
at org.modelmapper.ModelMapper.addMappings(ModelMapper.java:92)
at Main.initializeModelMapper(Main.java:169)
at Main.main(Main.java:25)
So, not sure if I'm doing something wrong? The only thing I can think of is that field matching is enabled (enableFieldMatching(true))?
Thanks,
Sascha