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

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.IConfigurationConverter;
import com.github.aureliano.evtbridge.core.helper.DataHelper;
import com.github.aureliano.evtbridge.core.schedule.IScheduler;

public class SchedulerConverter implements IConfigurationConverter<IScheduler> {

	public SchedulerConverter() {
		super();
	}

	@Override
	public IScheduler convert(Map<String, Object> data) {
		Map<String, Object> map = DataHelper.getAsHash(data, "scheduler");
		if (map == null) {
			return null;
		}
		
		String type = StringHelper.parse(map.get("type"));
		return SchedulerConverterFactory.createConverter(type).convert(map);
	}
	
	@Override
	public String id() {
		return ConverterType.SCHEDULER.name();
	}
}
@@ -74,79 +74,40 @@
 til.
-Map
+Iterator
 ;%0A
-%0A
 import 
-com.github.aureliano.evtbridge.common.helper.StringHelper;
+java.util.Map;%0A
 %0Aimp
@@ -554,20 +554,19 @@
 Object%3E 
-data
+map
 ) %7B%0A%09%09Ma
@@ -583,19 +583,29 @@
 Object%3E 
-map
+configuration
  = DataH
@@ -624,12 +624,11 @@
 ash(
-data
+map
 , %22s
@@ -645,19 +645,29 @@
 ;%0A%09%09if (
-map
+configuration
  == null
@@ -696,61 +696,232 @@
 %7D%0A%09%09
-%0A%09%09String type = StringHelper.parse(map
+Iterator%3CString%3E keys = configuration.keySet().iterator();%0A%0A%09%09String type = (keys.hasNext()) ? keys.next() : %22%22;%0A%09%09@SuppressWarnings(%22unchecked%22)%0A%09%09Map%3CString, Object%3E data = (Map%3CString, Object%3E) configuration
 .get(
-%22
 type
-%22)
 );
+%0A%09%09
 %0A%09%09r
@@ -982,19 +982,20 @@
 convert(
-map
+data
 );%0A%09%7D%0A%09%0A

Fix scheduler converter.