net.amygdalum.util.text.linkeddawg.LinkedByteFallbackDawgCompiler Maven / Gradle / Ivy
package net.amygdalum.util.text.linkeddawg;
import static net.amygdalum.util.text.ByteFallbackAdaptor.getFallback;
import static net.amygdalum.util.text.ByteFallbackAdaptor.setFallback;
import net.amygdalum.util.text.ByteDawg;
import net.amygdalum.util.text.ByteWordGraphCompiler;
import net.amygdalum.util.text.ByteNode;
import net.amygdalum.util.text.NodeResolver;
public class LinkedByteFallbackDawgCompiler implements ByteWordGraphCompiler> {
@Override
public ByteNode create() {
return new ByteGenericFallbackNode<>();
}
@Override
public ByteDawg build(ByteNode node) {
return new LinkedByteFallbackDawg<>(node);
}
@Override
public NodeResolver> resolver() {
return new ByteNodesCompiler() {
protected ByteNode compileNode(ByteNode node) {
ByteNode optimizedNode = ByteTerminalFallbackNode.buildNodeFrom(node, this);
if (optimizedNode != null) {
return optimizedNode;
}
optimizedNode = ByteArrayFallbackNode.buildNodeFrom(node, this);
if (optimizedNode != null) {
return optimizedNode;
}
return null;
}
@Override
public void link(ByteNode node) {
ByteNode fallbackNode = getFallback(node);
if (fallbackNode != null) {
ByteNode compiledFallbackNode = resolve(fallbackNode);
setFallback(node, compiledFallbackNode);
}
}
};
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy