### Question:
TypedFactory { public T createAnnotated(String className, Map<Object, Object> map){ Class<? extends T> clazz; try { clazz = (Class<? extends T>) ClassLoader .getSystemClassLoader().loadClass(getClassName(className)); } catch (ClassNotFoundException e1) { return null; } Constructor[] constructors = clazz.getConstructors(); find: for(Constructor constructor : constructors){ ParameterNames paramNames = (ParameterNames) constructor.getAnnotation(ParameterNames.class); if(paramNames==null){ continue ; } Parameter[] params = constructor.getParameters(); List<String> names = new ArrayList<String>(); List<Class> types = new ArrayList<Class>(); Set<String> canBeNull = new HashSet<String>(); for(int i=0;i<params.length;i++){ Parameter p = params[i]; names.add(paramNames.names()[i]); types.add(p.getType()); if(p.isAnnotationPresent(Nullable.class)){ canBeNull.add(p.getName()); } } List<Object> instanceNames = new ArrayList<Object>(map.keySet()); Object[] constructorArgs = new Object[names.size()]; if(!checkIfFits(map, names, canBeNull)){continue;} for(Object key : instanceNames){ Object value = map.get(key); int indexKey = names.indexOf(key.toString()); Class<?> clazz2 = types.get(indexKey); if(!clazz2.isInstance(value)){ continue find; } constructorArgs[indexKey] = value; } try { return (T) constructor.newInstance(constructorArgs); } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | SecurityException e) { LOGGER.error("Could not initialize class " + clazz.getName() + " with constructor.", e); return null; } } LOGGER.error("Could not initialize class " + clazz.getName() + " with constructor. Maybe Config file has wrong names?."); return null; }  @SuppressWarnings("unchecked") T create(String className, Object[] constructorArgs); @SuppressWarnings("unchecked") T create(String className,
			Object[] constructorArgs, Class<?>[] constructorClasses); T create(String className, Map<Object, Object> map); T createAnnotated(String className, Map<Object, Object> map);  }### Answer:
@Test public void mapCreationTestParameterNames() { TypedFactory<FactorizedObject> factory = new TypedFactory<FactorizedObject>(); Map arguments = new HashMap(); arguments.put("a", "a4"); arguments.put("b", "b4"); arguments.put("c", "c4"); FactorizedObject testObject = factory.createAnnotated("org.aksw.iguana.commons.factory.AnnotatedFactorizedObject", arguments); assertEquals("a4", testObject.getArgs()[0]); assertEquals("b4", testObject.getArgs()[1]); assertEquals("c4", testObject.getArgs()[2]); arguments.clear(); arguments.put("a", "a5"); testObject = factory.createAnnotated("org.aksw.iguana.commons.factory.AnnotatedFactorizedObject", arguments); assertEquals("a5", testObject.getArgs()[0]); assertEquals("wasNull", testObject.getArgs()[1]); }