aboutsummaryrefslogtreecommitdiffstats
path: root/container-search/src/main/java/com/yahoo/prelude/semantics/rule/ChoiceCondition.java
diff options
context:
space:
mode:
Diffstat (limited to 'container-search/src/main/java/com/yahoo/prelude/semantics/rule/ChoiceCondition.java')
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/semantics/rule/ChoiceCondition.java33
1 files changed, 33 insertions, 0 deletions
diff --git a/container-search/src/main/java/com/yahoo/prelude/semantics/rule/ChoiceCondition.java b/container-search/src/main/java/com/yahoo/prelude/semantics/rule/ChoiceCondition.java
new file mode 100644
index 00000000000..5cf3d4bf7a4
--- /dev/null
+++ b/container-search/src/main/java/com/yahoo/prelude/semantics/rule/ChoiceCondition.java
@@ -0,0 +1,33 @@
+// Copyright 2016 Yahoo Inc. 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 <a href="mailto:bratseth@yahoo-inc.com">Jon S Bratseth</a>
+ */
+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(", ");
+ }
+
+}