package info.bukova.isspst;

import java.util.HashMap;
import java.util.Map;

public class UrlResolverHolder {
	
	private EntityUrlResolver commonResolver;
	private Map<Class<?>, EntityUrlResolver> resolvers;
	
	public UrlResolverHolder(EntityUrlResolver common) {
		this.commonResolver = common;
		resolvers = new HashMap<Class<?>, EntityUrlResolver>();
	}

	public void setResolvers(Map<Class<?>, EntityUrlResolver> resolvers) {
		this.resolvers = resolvers;
	}
	
	public EntityUrlResolver resolverFor(Class<?> clazz) {
		EntityUrlResolver res = resolvers.get(clazz);
		
		if (res == null) {
			return commonResolver;
		}
		
		return res;
	}

}
