class Mapper implements ResourceLoaderAware {

	public Object map(Object toMap) {
		
		if (toMap == null) {
			return null;
		}
		
		Class<?> mappedClass = mappings.get(toMap.getClass());
		if (mappedClass != null) {
			return modelMapper.map(toMap, mappedClass);			
		} else {
			return toMap;
		}
	}

}

class MapperTest {

	@Autowired
	private Mapper mapper;

	@Test
	public void shouldDetectAnnotationAndMapObjectToDTO() {

		MovieInfo m = new MovieInfo("Iron Man 3", 2013, "HD");
		Object dto = mapper.map(m);
		assertTrue(dto instanceof Movie);
		assertEquals("Iron Man 3", ((Movie)dto).getName());
		assertEquals(new Integer(2013), ((Movie)dto).getYear());
		assertEquals(Quality.HD, ((Movie)dto).getQuality());
	}

}