01: package org.drools.rule;
02:
03: import org.drools.common.InternalWorkingMemory;
04: import org.drools.reteoo.ReteTuple;
05: import org.drools.spi.Extractor;
06: import org.drools.spi.Restriction;
07:
08: public class AndCompositeRestriction extends
09: AbstractCompositeRestriction {
10:
11: private static final long serialVersionUID = 400L;
12:
13: public AndCompositeRestriction(final Restriction[] restriction) {
14: super (restriction);
15: }
16:
17: public boolean isAllowed(final Extractor extractor,
18: final Object object,
19: final InternalWorkingMemory workingMemory) {
20: for (int i = 0, ilength = this .restrictions.length; i < ilength; i++) {
21: if (!this .restrictions[i].isAllowed(extractor, object,
22: workingMemory)) {
23: return false;
24: }
25: }
26: return true;
27: }
28:
29: public boolean isAllowedCachedLeft(final ContextEntry context,
30: final Object object) {
31: for (int i = 0, ilength = this .restrictions.length; i < ilength; i++) {
32: if (!this .restrictions[i].isAllowedCachedLeft(
33: this .contextEntry.contextEntries[i], object)) {
34: return false;
35: }
36: }
37: return true;
38: }
39:
40: public boolean isAllowedCachedRight(final ReteTuple tuple,
41: final ContextEntry context) {
42: for (int i = 0, ilength = this .restrictions.length; i < ilength; i++) {
43: if (!this .restrictions[i].isAllowedCachedRight(tuple,
44: this .contextEntry.contextEntries[i])) {
45: return false;
46: }
47: }
48: return true;
49: }
50:
51: }
|