package com.github.aureliano.evtbridge.converter.input;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;

import com.github.aureliano.evtbridge.common.helper.StringHelper;
import com.github.aureliano.evtbridge.converter.ConverterType;
import com.github.aureliano.evtbridge.core.config.IConfigInput;
import com.github.aureliano.evtbridge.core.config.IConfigurationConverter;

public class InputConverter implements IConfigurationConverter<List<IConfigInput>> {

	public InputConverter() {
		super();
	}

	@Override
	public List<IConfigInput> convert(Map<String, Object> data) {
		@SuppressWarnings("unchecked")
		List<Map<String, Object>> list = (List<Map<String, Object>>) data.get("inputConfigs");
		
		if (list == null) {
			return Collections.emptyList();
		}
		
		List<IConfigInput> inputs = new ArrayList<IConfigInput>();
		
		for (Map<String, Object> outputMap : list) {
			inputs.add(this.convertInput(outputMap));
		}
		
		return inputs;
	}
	
	@Override
	public String id() {
		return ConverterType.INPUT.name();
	}

	private IConfigInput convertInput(Map<String, Object> data) {
		String type = StringHelper.parse(data.get("type"));
		return (IConfigInput) InputConverterFactory.createConverter(type).convert(data);
	}
}
@@ -125,20 +125,24 @@
 va.util.
-List
+Iterator
 ;%0Aimport
@@ -156,21 +156,21 @@
 til.
-Map;%0A
+List;
 %0Aimport 
 com.
@@ -169,66 +169,23 @@
 ort 
-com.github.aureliano.evtbridge.common.helper.StringHelper;
+java.util.Map;%0A
 %0Aimp
@@ -1103,58 +1103,110 @@
 %7B%0A%09%09
-String type = StringHelper.parse(data.get(%22type%22))
+Iterator%3CString%3E keys = data.keySet().iterator();%0A%0A%09%09String type = (keys.hasNext()) ? keys.next() : %22%22
 ;%0A%09%09

Fix input type discovering.