aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib/src/main/java/com/yahoo/searchlib/expression/NumericFunctionNode.java
blob: 54f4b8b7be72202e30d6fcf14120c5b071f19a1f (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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.searchlib.expression;

/**
 * This is an abstract class for all functions that perform arithmetics. This node implements the necessary API for
 * doing arithmetic operations.
 *
 * @author Ulf Lilleengen
 */
public abstract class NumericFunctionNode extends MultiArgFunctionNode {

    @Override
    public void onPrepare() {
        super.onPrepare();

        ResultNode result = getResult();
        if (!(result instanceof IntegerResultNode) &&
            !(result instanceof FloatResultNode) &&
            !(result instanceof StringResultNode) &&
            !(result instanceof RawResultNode))
        {
            throw new RuntimeException("Can not perform numeric function on value of type '" +
                                       getResult().getClass().getName() + "'.");
        }
    }

    @Override
    protected final boolean equalsMultiArgFunction(MultiArgFunctionNode obj) {
        return true;
    }
}