blob: f868d9c0174b4c89a62aefe32cd0703b1f05d70c (
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
|
// 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 com.yahoo.prelude.semantics.RuleBase;
import com.yahoo.prelude.semantics.engine.RuleEvaluation;
/**
* A condition which matches if its contained condition doesn't.
* NotCondition inverts the term checking but not the label checking.
* That is, it means "label:!term", it does not mean "!label:term".
*
* @author bratseth
*/
public class NotCondition extends Condition {
private Condition condition;
public NotCondition(Condition condition) {
this.condition=condition;
}
public Condition getCondtiion() { return condition; }
public void setCondition(Condition condition) { this.condition=condition; }
protected boolean doesMatch(RuleEvaluation e) {
e.setInNegation(!e.isInNegation());
boolean matches=!condition.matches(e);
e.setInNegation(!e.isInNegation());
return matches;
}
public String toInnerString() {
return "!" + condition;
}
public void makeReferences(RuleBase ruleBase) {
condition.makeReferences(ruleBase);
}
protected boolean hasOpenChoicepoint(RuleEvaluation evaluation) {
return condition.hasOpenChoicepoint(evaluation);
}
}
|