aboutsummaryrefslogtreecommitdiffstats
path: root/container-search/src/main/java/com/yahoo/prelude/semantics/rule/ChoiceCondition.java
blob: 19299adf0313a223b43c19bba34056aec6437fc7 (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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.prelude.semantics.rule;

import java.util.Iterator;

import com.yahoo.prelude.semantics.engine.RuleEvaluation;

/**
 * A condition which consists of a list of alternatives to match at a specific location
 *
 * @author bratseth
 */
public class ChoiceCondition extends CompositeCondition {

    public ChoiceCondition() {
    }

    public boolean doesMatch(RuleEvaluation e) {
        //if (e.currentItem()==null) return false;
        for (Iterator<Condition> i=conditionIterator(); i.hasNext(); ) {
            Condition subCondition= i.next();
            if (subCondition.matches(e))
                return true;
        }

        return false;
    }

    protected String toInnerString() {
         return toInnerString(", ");
     }

}