01: package org.drools.reteoo;
02:
03: /*
04: * Copyright 2005 JBoss Inc
05: *
06: * Licensed under the Apache License, Version 2.0 (the "License");
07: * you may not use this file except in compliance with the License.
08: * You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing, software
13: * distributed under the License is distributed on an "AS IS" BASIS,
14: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: */
18:
19: import org.drools.WorkingMemory;
20: import org.drools.rule.Declaration;
21: import org.drools.rule.EvalCondition;
22: import org.drools.spi.EvalExpression;
23: import org.drools.spi.Tuple;
24:
25: public class MockEvalCondition extends EvalCondition {
26:
27: /**
28: *
29: */
30: private static final long serialVersionUID = 400L;
31:
32: private Boolean isAllowed;
33:
34: private final EvalExpression expression = new EvalExpression() {
35: /**
36: *
37: */
38: private static final long serialVersionUID = 400L;
39:
40: public boolean evaluate(Tuple tuple,
41: Declaration[] requiredDeclarations,
42: WorkingMemory workingMemory) {
43: return MockEvalCondition.this .isAllowed.booleanValue();
44: }
45: };
46:
47: public MockEvalCondition(final boolean isAllowed) {
48: this (isAllowed, null);
49: }
50:
51: public MockEvalCondition(final boolean isAllowed,
52: final Declaration[] requiredDeclarations) {
53: super (requiredDeclarations);
54: setEvalExpression(this .expression);
55: setIsAllowed(isAllowed);
56: }
57:
58: public MockEvalCondition(final EvalExpression eval,
59: final Declaration[] requiredDeclarations) {
60: super (eval, requiredDeclarations);
61: }
62:
63: public void setIsAllowed(final boolean isAllowed) {
64: this .isAllowed = new Boolean(isAllowed);
65: }
66: }
|