package eu.ydp.empiria.player.client.controller.feedback.matcher;

import java.util.Map;

import com.google.common.collect.Maps;
import com.google.inject.Inject;

import eu.ydp.empiria.player.client.controller.feedback.structure.condition.AndConditionBean;
import eu.ydp.empiria.player.client.controller.feedback.structure.condition.CountConditionBean;
import eu.ydp.empiria.player.client.controller.feedback.structure.condition.FeedbackCondition;
import eu.ydp.empiria.player.client.controller.feedback.structure.condition.NotConditionBean;
import eu.ydp.empiria.player.client.controller.feedback.structure.condition.OrConditionBean;
import eu.ydp.empiria.player.client.controller.feedback.structure.condition.PropertyConditionBean;

public class MatcherRegistry {
	
	Map<Class<? extends FeedbackCondition>, FeedbackMatcher> map;
	
	
	public MatcherRegistry() {
		map = Maps.newHashMap();
	}
	
	@Inject
	public void setMatcherRegistry(MatcherRegistryFactory factory) {
		map.put(CountConditionBean.class, factory.getCountConditionMatcher());
		map.put(PropertyConditionBean.class, factory.getPropertyConditionMatcher());
		map.put(AndConditionBean.class, factory.getAndConditionMatcher());
		map.put(OrConditionBean.class, factory.getOrConditionMatcher());
		map.put(NotConditionBean.class, factory.getNotConditionMatcher());
	}
	
	public FeedbackMatcher getMatcher(FeedbackCondition condition) {
		return map.get(condition.getClass());
	}

}

@@ -845,25 +845,31 @@
 p;%0D%0A%09%0D%0A%09
-%0D%0A%09public
+@Inject private
  Matcher
@@ -880,124 +880,78 @@
 stry
-() %7B%0D%0A%09%09map = Maps.newHashMap();%0D%0A%09%7D%0D%0A%09%0D%0A%09@Inject%0D%0A%09public void setMatcherRegistry(MatcherRegistryFactory factory) %7B
+Factory factory;%0D%0A%09%0D%0A%09public void init() %7B%0D%0A%09%09map = Maps.newHashMap();
 %0D%0A%09%09
@@ -1384,16 +1384,54 @@
 ion) %7B%0D%0A
+%09%09if (map == null)%7B%0D%0A%09%09%09init();%0D%0A%09%09%7D%0D%0A
 %09%09return

fix matcher registry initialization issue EMPCP-120