net.intelie.pipes.ast.AstVisitor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pipes-api Show documentation
Show all versions of pipes-api Show documentation
Intelie Pipes' API classes and interfaces
package net.intelie.pipes.ast;
import net.intelie.pipes.PipeException;
import java.util.ArrayList;
import java.util.List;
public abstract class AstVisitor {
public T visit(AstNode node) throws PipeException {
if (node instanceof CallNode)
return visitCall((CallNode) node);
if (node instanceof LiteralNode)
return visitLiteral((LiteralNode) node);
if (node instanceof RawNode)
return visitRaw((RawNode) node);
return visitUnknown(node);
}
public List visitList(List nodes) throws PipeException {
List list = new ArrayList<>();
for (AstNode node : nodes)
list.add(visit(node));
return list;
}
public T visitUnknown(AstNode node) throws PipeException {
throw new PipeException("Unknown node type: %s", node);
}
public abstract T visitRaw(RawNode node) throws PipeException;
public abstract T visitLiteral(LiteralNode node) throws PipeException;
public abstract T visitCall(CallNode node) throws PipeException;
}