All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.webpieces.templatingdev.impl.source.GenLookup Maven / Gradle / Ivy

There is a newer version: 2.1.109
Show newest version
package org.webpieces.templatingdev.impl.source;

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

import javax.inject.Inject;
import javax.inject.Singleton;

import org.webpieces.templatingdev.api.GroovyGen;
import org.webpieces.templatingdev.impl.tags.ElseGen;
import org.webpieces.templatingdev.impl.tags.ElseIfGen;
import org.webpieces.templatingdev.impl.tags.IfGen;
import org.webpieces.templatingdev.impl.tags.ListGen;

@Singleton
public class GenLookup {

	private final Map generators = new HashMap<>();
	
	private final ListGen listGen;

	@Inject
	public GenLookup(ListGen listGen) {
		super();
		this.listGen = listGen;
	}

	protected void init() {
		put(new IfGen());
		put(new ElseIfGen());
		put(new ElseGen());
		put(listGen);
	}

	protected void put(GroovyGen generator) {
		generators.put(generator.getName(), generator);
	}

	public GroovyGen lookup(String genName, TokenImpl token) {
		GroovyGen gen = generators.get(genName);
		return gen;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy