summaryrefslogtreecommitdiffstats
path: root/container-search/src/main/java/com/yahoo/prelude/semantics/rule/AndCondition.java
diff options
context:
space:
mode:
Diffstat (limited to 'container-search/src/main/java/com/yahoo/prelude/semantics/rule/AndCondition.java')
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/semantics/rule/AndCondition.java39
1 files changed, 39 insertions, 0 deletions
diff --git a/container-search/src/main/java/com/yahoo/prelude/semantics/rule/AndCondition.java b/container-search/src/main/java/com/yahoo/prelude/semantics/rule/AndCondition.java
new file mode 100644
index 00000000000..2c826df9196
--- /dev/null
+++ b/container-search/src/main/java/com/yahoo/prelude/semantics/rule/AndCondition.java
@@ -0,0 +1,39 @@
+// 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.Choicepoint;
+import com.yahoo.prelude.semantics.engine.RuleEvaluation;
+
+/**
+ * A condition which consists of a list of alternatives to match at any location
+ *
+ * @author <a href="mailto:bratseth@yahoo-inc.com">Jon S Bratseth</a>
+ */
+public class AndCondition extends CompositeCondition {
+
+ // TODO: Not in use. What was this for? Remove?
+
+ public AndCondition() {
+ }
+
+ public boolean doesMatch(RuleEvaluation e) {
+ Choicepoint choicepoint=e.getChoicepoint(this,true);
+ choicepoint.updateState();
+ boolean matches=allSubConditionsMatches(e);
+ if (!matches)
+ choicepoint.backtrack();
+ return matches;
+ }
+
+ protected boolean useParentheses() {
+ return (getParent()!=null
+ && ! (getParent() instanceof ChoiceCondition));
+ }
+
+ protected String toInnerString() {
+ return toInnerString(" & ");
+ }
+
+}