public Mapper getMapper(Map<String, Mapper> mappers, String targetClazzName) throws MapperNotFoundException { try { Mapper mapper; // check for array type if (targetClazzName.endsWith("[]")) { mapper = new RawTypeMapper(); return mapper; } mapper = mappers.get(targetClazzName); if (mapper != null) { logger.debug( "found mapper: " + mapper.getClass().getCanonicalName() + " for: " + targetClazzName); return mapper; } else { return getMapper(mappers, Class.forName(targetClazzName)); } } catch (ClassNotFoundException e) { e .printStackTrace(); // To change body of catch statement use File | Settings | File // Templates. } throw new MapperNotFoundException( "***DefaultConverter - cannot find mapper for: " + targetClazzName); }
public Mapper getMapper(Map<String, Mapper> mappers, Class targetClazz) throws MapperNotFoundException { Mapper mapper = mappers.get(targetClazz.getCanonicalName()); if (mapper == null) { // now we try to find if the target param is serizialiable, if so we could use // RawTypeMapper // java.io.Serializable for (Class clazz : targetClazz.getInterfaces()) { if (clazz.equals(java.io.Serializable.class) || clazz.isArray()) { mapper = new RawTypeMapper(); break; } } if (mapper == null) throw new MapperNotFoundException( "***DefaultConverter - cannot find mapper for: " + targetClazz.getCanonicalName()); } logger.debug( "found mapper: " + mapper.getClass().getCanonicalName() + " for: " + targetClazz.getCanonicalName()); return mapper; }