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

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

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

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

public class CharTerminalFallbackNode implements CharNode, CharFallbackAdaptor {

	private static final char[] NONE = new char[0];

	private CharNode fallbackNode;
	private T attached;

	private CharTerminalFallbackNode(T attached) {
		this.attached = attached;
	}

	public static  CharTerminalFallbackNode buildNodeFrom(CharNode node, NodeResolver> resolver) {
		if (node.getAlternativesSize() > 0) {
			return null;
		}
		CharTerminalFallbackNode buildNode = new CharTerminalFallbackNode<>(node.getAttached());
		CharNode fallbackNode = CharFallbackAdaptor.getFallback(node);
		if (fallbackNode != null) {
			buildNode.setFallback(fallbackNode);
		}
		return buildNode;
	}

	@Override
	public CharNode nextNode(char c) {
		return null;
	}

	@Override
	public T getAttached() {
		return attached;
	}

	@Override
	public char[] getAlternatives() {
		return NONE;
	}

	@Override
	public int getAlternativesSize() {
		return 0;
	}

	@Override
	public void setFallback(CharNode fallbackNode) {
		this.fallbackNode = fallbackNode;
	}

	@Override
	public CharNode getFallback() {
		return fallbackNode;
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy