this.mapperFacade = mapperFacade;
this.inPlace = inPlace;
}
public MappingStrategy getStrategy(Object sourceObject, MappingContext context) {
MappingStrategy strategy = null;
if (defaultStrategy != null && sourceObject.getClass().equals(idClass)) {
strategy = defaultStrategy;
} else if (defaultStrategy == null) {
synchronized(this) {
if (defaultStrategy == null) {
defaultStrategy = mapperFacade.resolveMappingStrategy(sourceObject, aType, bType, inPlace, context);
idClass = sourceObject.getClass();
}
}
strategy = defaultStrategy;
} else {
strategy = strategies.get(sourceObject.getClass());
if (strategy == null) {
strategy = mapperFacade.resolveMappingStrategy(sourceObject, aType, bType, inPlace, context);
strategies.put(sourceObject.getClass(), strategy);
}
}
/*
* Set the resolved types on the current mapping context; this can be used
* by downstream Mappers to determine the originally resolved types
*/
context.setResolvedSourceType(strategy.getSoureType());
context.setResolvedDestinationType(strategy.getDestinationType());
return strategy;
}