aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib/src/main/java/com/yahoo/searchlib/expression/NumericResultNode.java
blob: c01c3e2ea9719a8b0cd6e1f150a3e05aa79b6e75 (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
40
41
42
43
44
45
46
47
48
49
50
51
52
// 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 a superclass for all numerical results.
 *
 * @author baldersheim
 * @author Simon Thoresen Hult
 */
abstract public class NumericResultNode extends SingleResultNode {

    // The global class identifier shared with C++.
    public static final int classId = registerClass(0x4000 + 50, NumericResultNode.class);

    /**
     * In-place multiplication of this result with another.
     *
     * @param rhs The result to multiply with this.
     */
    public abstract void multiply(ResultNode rhs);

    /**
     * In-place division of this result with another.
     *
     * @param rhs The result to divide this by.
     */
    public abstract void divide(ResultNode rhs);

    /**
     * In-place modulo of this result with another.
     *
     * @param rhs The result to modulo this with.
     */
    public abstract void modulo(ResultNode rhs);

    /**
     * Return a java numeric, either Double or Long, depending on the underlying container.
     *
     * @return The underlying numeric value.
     */
    public abstract Object getNumber();

    @Override
    public Object getValue() {
        return getNumber();
    }

    @Override
    protected int onGetClassId() {
        return classId;
    }
}