aboutsummaryrefslogtreecommitdiffstats
path: root/config-model/src/main/java/com/yahoo/schema/parser/ParsedRankFunction.java
blob: 73f1316d468c196596063e2cb619bf6e4f88d137 (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
35
36
37
38
39
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.schema.parser;

import java.util.ArrayList;
import java.util.List;

/**
 * This class holds the extracted information after parsing a
 * "function" block in a rank-profile, using simple data structures as
 * far as possible.  Do not put advanced logic here!
 * @author arnej27959
 **/
class ParsedRankFunction extends ParsedBlock {

    private boolean inline;
    private String expression;
    private final List<String> parameters = new ArrayList<>();

    ParsedRankFunction(String name) {
        super(name, "function");
    }

    boolean getInline() { return this.inline; }
    String getExpression() { return this.expression; }
    List<String> getParameters() { return List.copyOf(parameters); }

    void addParameter(String param) {
        verifyThat(! parameters.contains(param), "cannot have parameter", param, "twice");
        parameters.add(param);
    }

    void setInline(boolean value) {
        this.inline = value;
    }

    void setExpression(String value) {
        this.expression = value;
    }
}