aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib/src/main/java/com/yahoo/searchlib/treenet/rule/ComparisonCondition.java
blob: c627e21ad6cdd4e85694698fa39da1795cbfdaf8 (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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.searchlib.treenet.rule;

/**
 * Represents a condition which comparing two values
 *
 * @author Simon Thoresen Hult
 */
public class ComparisonCondition extends Condition {

    private final double rhs;

    /**
     * Constructs a new instance of this class.
     *
     * @param lhs The name of the feature to compare to a constant.
     * @param rhs The constant to compare the feature with.
     * @param ift The label to jump to if left < right.
     * @param iff The label to jump to if left >= right;
     */
    public ComparisonCondition(String lhs, double rhs, String ift, String iff) {
        super(lhs, ift, iff);
        this.rhs = rhs;
    }

    /**
     * Returns the constant to compare the feature with.
     *
     * @return The constant.
     */
    public double getConstant() { return rhs; }

    @Override
    public String conditionToRankingExpression() {
        return "< " + String.valueOf(rhs);
    }
}