I'm using ModelMapper to do straight-forward maps between objects.
ModelMapper mapper = new ModelMapper();
// TypeMap created
mapper.map(sourceObj, destObj);
mapper = new ModelMapper();
// TypeMap is recreated
mapper.map(sourceObj, destObj);
I noticed in the source code that if a TypeMap
doesn't exist between sourceObj
and destObj
that it will cache the TypeMap
in getOrCreate
method.
As far as I can tell this cache is tied to the mapper instance, meaning that if I have to map the sourceObj
to destObj
for second time using a new ModelMapper instance, that it will have to re-create the TypeMap
.
I'm assuming this is a fairly expensive operation, say if I'm mapping a collection of sourceObj
to destObj
. This leads me to the conclusion that I should re-use the ModelMapper instance.
Is this conclusion correct?
thanks