use of io.mycat.hbt.ast.base.Literal in project Mycat2 by MyCATApache.
the class SchemaConvertor method values.
public List<Object> values(ParseNode fields) {
CallExpr callExpr = (CallExpr) fields;
List<ParseNode> exprs = callExpr.getArgs().getExprs();
return exprs.stream().map(i -> ((Literal) transforExpr(i)).getValue()).collect(Collectors.toList());
}
use of io.mycat.hbt.ast.base.Literal in project Mycat2 by MyCATApache.
the class SchemaConvertor method transforExpr.
public Expr transforExpr(ParseNode parseNode) {
if (parseNode instanceof CallExpr) {
CallExpr parseNode1 = (CallExpr) parseNode;
String name = parseNode1.getName();
List<ParseNode> exprs = parseNode1.getArgs().getExprs();
List<Expr> collect = exprs.stream().map(i -> transforExpr(i)).collect(Collectors.toList());
return new Fun(name, collect);
} else if (parseNode instanceof DecimalLiteral) {
return new Literal(((DecimalLiteral) parseNode).getNumber());
} else if (parseNode instanceof IdLiteral) {
return new Identifier(((IdLiteral) parseNode).getId());
} else if (parseNode instanceof StringLiteral) {
return new Literal(((StringLiteral) parseNode).getString());
} else if (parseNode instanceof IntegerLiteral) {
return new Literal(((IntegerLiteral) parseNode).getNumber());
} else if (parseNode instanceof ParenthesesExpr) {
ParenthesesExpr parseNode1 = (ParenthesesExpr) parseNode;
List<ParseNode> exprs = parseNode1.getExprs();
if (exprs.size() == 1) {
return transforExpr(exprs.get(0));
}
} else if (parseNode instanceof BooleanLiteral) {
return new Literal(((BooleanLiteral) parseNode).getValue());
} else if (parseNode instanceof NullLiteral) {
return new Literal(null);
} else if (parseNode instanceof ParamLiteral) {
if (params.isEmpty()) {
return new Param();
}
return new Literal(params.get(index++));
}
throw new UnsupportedOperationException();
}
Aggregations