net.amygdalum.util.text.linkeddawg.ByteTerminalFallbackNode 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.ByteFallbackAdaptor;
import net.amygdalum.util.text.ByteNode;
import net.amygdalum.util.text.NodeResolver;
public class ByteTerminalFallbackNode implements ByteNode, ByteFallbackAdaptor {
private static final byte[] NONE = new byte[0];
private ByteNode fallbackNode;
private T attached;
public ByteTerminalFallbackNode(T attached) {
this.attached = attached;
}
public static ByteTerminalFallbackNode buildNodeFrom(ByteNode node, NodeResolver> resolver) {
if (node.getAlternativesSize() > 0) {
return null;
}
ByteTerminalFallbackNode buildNode = new ByteTerminalFallbackNode<>(node.getAttached());
ByteNode fallbackNode = ByteFallbackAdaptor.getFallback(node);
if (fallbackNode != null) {
buildNode.setFallback(fallbackNode);
}
return buildNode;
}
@Override
public ByteNode nextNode(byte b) {
return null;
}
@Override
public T getAttached() {
return attached;
}
@Override
public byte[] getAlternatives() {
return NONE;
}
@Override
public int getAlternativesSize() {
return 0;
}
@Override
public void setFallback(ByteNode fallbackNode) {
this.fallbackNode = fallbackNode;
}
@Override
public ByteNode getFallback() {
return fallbackNode;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy