blob: ab44d9375599ae1ddd4471e1e6104db8688f160e (
plain)
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
/*******************************************************************************
* Copyright (c) 2009 Elliott Baron
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Elliott Baron - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.codan.extension;
import org.eclipse.cdt.core.dom.ast.IVariable;
public class ExecutionStateClause {
protected IVariable var;
protected boolean truthValue;
public ExecutionStateClause(IVariable var) {
this(var, true);
}
public ExecutionStateClause(IVariable var, boolean truthValue) {
this.var = var;
this.truthValue = truthValue;
}
public IVariable getVariable() {
return var;
}
public boolean isTrue() {
return truthValue;
}
public ExecutionStateClause getNegation() {
return new ExecutionStateClause(var, !truthValue);
}
@Override
public boolean equals(Object obj) {
if (obj instanceof ExecutionStateClause) {
ExecutionStateClause other = (ExecutionStateClause) obj;
return var.equals(other.getVariable()) && truthValue == other.isTrue();
}
return false;
}
@Override
public int hashCode() {
return var.hashCode() + (truthValue ? 1 : 0);
}
@Override
public String toString() {
StringBuffer buf = new StringBuffer();
if (!truthValue) {
buf.append("NOT ");
}
buf.append(var.getName());
return buf.toString();
}
}
|