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

import java.util.Map;

import com.github.aureliano.evtbridge.converter.ConfigurationConverter;
import com.github.aureliano.evtbridge.converter.ConfigurationSourceType;
import com.github.aureliano.evtbridge.converter.exception.ConfigurationConverterException;
import com.github.aureliano.evtbridge.core.config.EventCollectorConfiguration;
import com.github.aureliano.evtbridge.core.helper.DataHelper;
import com.github.aureliano.evtbridge.core.helper.FileHelper;

public final class ConversionHelper {

	private ConversionHelper() {}
	
	public static EventCollectorConfiguration loadConfiguration(String path, ConfigurationSourceType type) {
		switch (type) {
			case YAML: return null;
			case JSON: return convertFromJson(path);
			default: throw new ConfigurationConverterException("Configuration source type '" + type + "' not supported.");
		}
	}
	
	private static EventCollectorConfiguration convertFromJson(String path) {
		String text = FileHelper.readFile(path);
		@SuppressWarnings("unchecked")
		Map<String, Object> data = DataHelper.jsonStringToObject(text, Map.class);
		
		return new ConfigurationConverter().convert(data);
	}
}
@@ -735,12 +735,29 @@
 urn 
-null
+convertFromYaml(path)
 ;%0A%09%09
@@ -1208,9 +1208,298 @@
 ta);%0A%09%7D%0A
+%09%0A%09private static EventCollectorConfiguration convertFromYaml(String path) %7B%0A%09%09String text = FileHelper.readFile(path);%0A%09%09@SuppressWarnings(%22unchecked%22)%0A%09%09Map%3CString, Object%3E data = DataHelper.yamlStringToObject(text, Map.class);%0A%09%09%0A%09%09return new ConfigurationConverter().convert(data);%0A%09%7D%0A
 %7D

Handle yaml parsing.