test_class.file: iguana.commons/src/test/java/org/aksw/iguana/commons/factory/TypedFactoryTest.java
test_class.identifier: TypedFactoryTest
test_case.body: @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]);
  	}
test_case.class_method_signature: TypedFactoryTest.mapCreationTestParameterNames()
test_case.full_signature: @Test public void mapCreationTestParameterNames()
test_case.identifier: mapCreationTestParameterNames
test_case.invocations: put put put createAnnotated assertEquals getArgs assertEquals getArgs assertEquals getArgs clear put createAnnotated assertEquals getArgs assertEquals getArgs
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void mapCreationTestParameterNames()
focal_class.declarator: LOGGER = LoggerFactory
  			.getLogger(TypedFactory.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger LOGGER = LoggerFactory
  			.getLogger(TypedFactory.class);
focal_class.type: Logger
focal_class.var_name: LOGGER
focal_class.file: iguana.commons/src/main/java/org/aksw/iguana/commons/factory/TypedFactory.java
focal_class.identifier: TypedFactory
focal_class.class_method_signature: TypedFactory.getClassName(String className)
focal_class.full_signature: private String getClassName(String className)
focal_class.identifier: getClassName
focal_class.modifiers: private
focal_class.parameters: (String className)
focal_class.return: String
focal_class.signature: String getClassName(String className)
focal_class.class_method_signature: TypedFactory.create(String className, Object[] constructorArgs)
focal_class.full_signature: @SuppressWarnings("unchecked") public T create(String className, Object[] constructorArgs)
focal_class.identifier: create
focal_class.modifiers: @SuppressWarnings("unchecked") public
focal_class.parameters: (String className, Object[] constructorArgs)
focal_class.return: T
focal_class.signature: T create(String className, Object[] constructorArgs)
focal_class.class_method_signature: TypedFactory.create(String className,
  			Object[] constructorArgs, Class<?>[] constructorClasses)
focal_class.full_signature: @SuppressWarnings("unchecked") public T create(String className,
  			Object[] constructorArgs, Class<?>[] constructorClasses)
focal_class.identifier: create
focal_class.modifiers: @SuppressWarnings("unchecked") public
focal_class.parameters: (String className,
  			Object[] constructorArgs, Class<?>[] constructorClasses)
focal_class.return: T
focal_class.signature: T create(String className,
  			Object[] constructorArgs, Class<?>[] constructorClasses)
focal_class.class_method_signature: TypedFactory.create(String className, Map<Object, Object> map)
focal_class.full_signature: public T create(String className, Map<Object, Object> map)
focal_class.identifier: create
focal_class.modifiers: public
focal_class.parameters: (String className, Map<Object, Object> map)
focal_class.return: T
focal_class.signature: T create(String className, Map<Object, Object> map)
focal_class.class_method_signature: TypedFactory.checkIfFits(Map<Object, Object>  map, List<String> names, Set<String> canBeNull)
focal_class.full_signature: private boolean checkIfFits(Map<Object, Object>  map, List<String> names, Set<String> canBeNull)
focal_class.identifier: checkIfFits
focal_class.modifiers: private
focal_class.parameters: (Map<Object, Object>  map, List<String> names, Set<String> canBeNull)
focal_class.return: boolean
focal_class.signature: boolean checkIfFits(Map<Object, Object>  map, List<String> names, Set<String> canBeNull)
focal_class.class_method_signature: TypedFactory.createAnnotated(String className, Map<Object, Object> map)
focal_class.full_signature: public T createAnnotated(String className, Map<Object, Object> map)
focal_class.identifier: createAnnotated
focal_class.modifiers: public
focal_class.parameters: (String className, Map<Object, Object> map)
focal_class.return: T
focal_class.signature: T createAnnotated(String className, Map<Object, Object> map)
focal_method.body: 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);
  				//Check if constructor can map keys to param Names
  				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) {
  				//As we check that the Constructor fits this shouldn't be thrown at all. Something very bad happend
  				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;
  	}
focal_method.class_method_signature: TypedFactory.createAnnotated(String className, Map<Object, Object> map)
focal_method.full_signature: public T createAnnotated(String className, Map<Object, Object> map)
focal_method.identifier: createAnnotated
focal_method.invocations: loadClass getSystemClassLoader getClassName getConstructors getAnnotation getParameters add names add getType isAnnotationPresent add getName keySet size checkIfFits get indexOf toString get isInstance newInstance error getName error getName
focal_method.modifiers: public
focal_method.parameters: (String className, Map<Object, Object> map)
focal_method.return: T
focal_method.signature: T createAnnotated(String className, Map<Object, Object> map)