blob: 8dd3e949a49221dd7756d7aff742ab95e772eeee (
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
48
49
50
51
52
|
/*******************************************************************************
* Copyright (c) 2004-2008 Gabor Bergmann and Daniel Varro
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-v20.html.
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
package tools.refinery.viatra.runtime.rete.single;
import tools.refinery.viatra.runtime.matchers.tuple.Tuple;
import tools.refinery.viatra.runtime.matchers.tuple.TupleMask;
import tools.refinery.viatra.runtime.rete.network.ReteContainer;
/**
* This node filters patterns according to equalities and inequalities of elements. The 'subject' element is asserted to
* be different from the elements given by the inequalityMask.
*
*
* @author Gabor Bergmann
*
*/
public class InequalityFilterNode extends FilterNode {
int subjectIndex;
TupleMask inequalityMask;
/**
* @param reteContainer
* @param subject
* the index of the element that should be compared.
* @param inequalityMask
* the indices of elements that should be different from the subjectIndex.
*/
public InequalityFilterNode(ReteContainer reteContainer, int subject, TupleMask inequalityMask) {
super(reteContainer);
this.subjectIndex = subject;
this.inequalityMask = inequalityMask;
}
@Override
public boolean check(Tuple ps) {
Object subject = ps.get(subjectIndex);
for (int ineq : inequalityMask.indices) {
if (subject.equals(ps.get(ineq)))
return false;
}
return true;
}
}
|