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

net.amygdalum.util.text.linkeddawg.CharNodesCompiler Maven / Gradle / Ivy

The newest version!
package net.amygdalum.util.text.linkeddawg;

import java.util.IdentityHashMap;
import java.util.Map;

import net.amygdalum.util.text.CharNode;
import net.amygdalum.util.text.NodeResolver;

public abstract class CharNodesCompiler implements NodeResolver> {

	private Map, CharNode> compiled;

	public CharNodesCompiler() {
		this.compiled = new IdentityHashMap<>();
	}

	@Override
	public void compile(CharNode node) {
		compiled.put(node, compileNode(node));
	}

	protected abstract CharNode compileNode(CharNode node);

	@Override
	public CharNode resolve(CharNode node) {
		CharNode compiledNode = compiled.get(node);
		if (compiledNode == null) {
			return node;
		}
		return compiledNode;
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy