aboutsummaryrefslogtreecommitdiffstats
path: root/container-search/src/main/java/com/yahoo/search/yql/ProjectOperator.java
blob: b1ed03eeaf148f8b4c9e94068406463348af9511 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.yql;

import com.google.common.base.Predicate;

/**
 * Represents a projection command which affects the output record.
 */
enum ProjectOperator implements Operator {

    FIELD(ExpressionOperator.class, String.class),  // FIELD expr name
    RECORD(ExpressionOperator.class, String.class), // RECORD expr name
    MERGE_RECORD(String.class);                     // MERGE_RECORD name (alias of record to merge)

    private final ArgumentsTypeChecker checker;

    public static Predicate<OperatorNode<? extends Operator>> IS = new Predicate<OperatorNode<? extends Operator>>() {
        @Override
        public boolean apply(OperatorNode<? extends Operator> input) {
            return input.getOperator() instanceof ProjectOperator;
        }
    };

    private ProjectOperator(Object... types) {
        checker = TypeCheckers.make(this, types);
    }


    @Override
    public void checkArguments(Object... args) {
        checker.check(args);
    }

}