net.amygdalum.util.text.linkeddawg.CharTerminalFallbackNode Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of compilerutils Show documentation
Show all versions of compilerutils Show documentation
Utility classes needed for search and compiler applications
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