/** * Constructor takes a {@link StringFilterClause} object to construct from. * * @param stringFilterClause The {@link StringFilterClause} object tor construct from. */ public ObjectFilterClause(StringFilterClause stringFilterClause) { this.operation = stringFilterClause.operation; this.field = stringFilterClause.field; this.patterns = stringFilterClause.patterns; List<String> stringValues = stringFilterClause.getValues(); if (stringValues != null) { values = stringValues.stream().map(s -> s == null ? null : new Value(Value.Kind.VALUE, s)).collect(Collectors.toList()); } }
private Clause createFilterClause(Operation operation, String field, String... values) { FilterClause filterClause = new ObjectFilterClause(); filterClause.setOperation(operation); filterClause.setField(field); filterClause.setValues(Stream.of(values).map(v -> new Value(Value.Kind.VALUE, v)).collect(Collectors.toList())); return filterClause; }
private Clause createFilterClause(Operation operation, String field, Expression... expressions) { FilterClause filterClause = new ObjectFilterClause(); filterClause.setOperation(operation); filterClause.setField(field); filterClause.setValues(Stream.of(expressions).map(e -> new Value(e instanceof Identifier ? Value.Kind.FIELD : Value.Kind.VALUE, e.toFormatlessString())).collect(Collectors.toList())); return filterClause; }
@Override protected com.yahoo.bullet.parsing.Expression visitIdentifier(Identifier node, Void context) { LeafExpression leafExpression = new LeafExpression(); leafExpression.setValue(new Value(Value.Kind.FIELD, node.toFormatlessString())); return leafExpression; } }
@Override protected com.yahoo.bullet.parsing.Expression visitBooleanLiteral(BooleanLiteral node, Void context) { LeafExpression leafExpression = new LeafExpression(); leafExpression.setValue(new Value(Value.Kind.VALUE, node.toFormatlessString(), Type.BOOLEAN)); return leafExpression; }
@Override protected com.yahoo.bullet.parsing.Expression visitDecimalLiteral(DecimalLiteral node, Void context) { LeafExpression leafExpression = new LeafExpression(); leafExpression.setValue(new Value(Value.Kind.VALUE, node.toFormatlessString(), Type.DOUBLE)); return leafExpression; }
@Override protected com.yahoo.bullet.parsing.Expression visitLongLiteral(LongLiteral node, Void context) { LeafExpression leafExpression = new LeafExpression(); leafExpression.setValue(new Value(Value.Kind.VALUE, node.toFormatlessString(), Type.LONG)); return leafExpression; }
@Override protected com.yahoo.bullet.parsing.Expression visitDoubleLiteral(DoubleLiteral node, Void context) { LeafExpression leafExpression = new LeafExpression(); leafExpression.setValue(new Value(Value.Kind.VALUE, node.toFormatlessString(), Type.DOUBLE)); return leafExpression; }
@Override protected com.yahoo.bullet.parsing.Expression visitStringLiteral(StringLiteral node, Void context) { LeafExpression leafExpression = new LeafExpression(); leafExpression.setValue(new Value(Value.Kind.VALUE, node.toFormatlessString(), Type.STRING)); return leafExpression; }
@Override protected com.yahoo.bullet.parsing.Expression visitArithmeticUnary(ArithmeticUnaryExpression node, Void context) { LeafExpression leafExpression = new LeafExpression(); Type type; if (node.getValue() instanceof LongLiteral) { type = Type.LONG; } else { type = Type.DOUBLE; } leafExpression.setValue(new Value(Value.Kind.VALUE, node.toFormatlessString(), type)); return leafExpression; }
protected com.yahoo.bullet.parsing.Expression visitCastExpression(CastExpression node, Void context) throws ParsingException { if (containsCastExpression(node.getExpression())) { throw new ParsingException("Casting of cast expressions is not supported"); } com.yahoo.bullet.parsing.Expression expression = process(node.getExpression()); if (expression instanceof BinaryExpression) { ((BinaryExpression) expression).setType(Type.valueOf(node.getCastType().toUpperCase())); } else { Value value = ((LeafExpression) expression).getValue(); ((LeafExpression) expression).setValue(new Value(value.getKind(), value.getValue(), Type.valueOf(node.getCastType().toUpperCase()))); } return expression; }