// private methods - each method represents the invocation of a single rule // for a certain query // query: isFrequentCustomer // rule: rule1: (c.getTransactionCount())>5 -> FrequentCustomer(c); private static ResourceIterator<FrequentCustomerRel> isFrequentCustomer_0( final DerivationController _derivation, final Customer customer) { _derivation.log( "test.org.mandarax.compiler.reldef7.FrequentCustomer.rule1", DerivationController.RULE, _annotations_rule1); // utility class used to keep track of variables bindings // rule: rule1: (c.getTransactionCount())>5 -> FrequentCustomer(c); // prereqs: [(c.getTransactionCount())>5] class _Bindings { private test.org.mandarax.compiler.Customer c = customer; } final _Bindings _bindings = new _Bindings(); ResourceIterator<?> _tmp = null; // apply prerequisite (c.getTransactionCount())>5 // case 4 if (!((_bindings.c.getTransactionCount()) > 5)) { return EmptyIterator.DEFAULT; } // rule head return new SingletonIterator(new FrequentCustomerRel(_bindings.c)); }
// private methods - each method represents the invocation of a single rule // for a certain query // query: isSemiOrphan // rule: rule1: isYoung(p) & Father(f,p) & not Mother(m,p) -> SemiOrphan(p); private static ResourceIterator<SemiOrphanRel> isSemiOrphan_0( final DerivationController _derivation, final Person person) { _derivation.log( "test.org.mandarax.compiler.naf1.SemiOrphan.rule1", DerivationController.RULE, _annotations_rule1); // utility class used to keep track of variables bindings // rule: rule1: isYoung(p) & Father(f,p) & not Mother(m,p) -> // SemiOrphan(p); // prereqs: [isYoung(p), Father(f,p), not Mother(m,p)] class _Bindings { private test.org.mandarax.compiler.Person p = person; private test.org.mandarax.compiler.Person f = null; private test.org.mandarax.compiler.Person m = null; } final _Bindings _bindings = new _Bindings(); ResourceIterator<?> _tmp = null; // apply prerequisite isYoung(p) // case 4 _tmp = isYoungRelInstances.isYoung(_derivation.push(), _bindings.p); if (!_tmp.hasNext()) { _tmp.close(); return EmptyIterator.DEFAULT; } // apply prerequisite Father(f,p) // case 1 final ResourceIterator<FatherRel> _iterator2 = FatherRelInstances.getFather(_derivation.push(), _bindings.p); // apply prerequisite not Mother(m,p) // case 3 com.google.common.base.Predicate<FatherRel> _filter3 = new com.google.common.base.Predicate<FatherRel>() { public boolean apply(FatherRel _object) { // bind parameters from Father(f,p) _bindings.f = _object.father; ResourceIterator<MotherRel> _r = MotherRelInstances.getMother(_derivation.push(), _bindings.p); boolean _b = _r.hasNext(); _r.close(); return !_b; } }; final ResourceIterator<FatherRel> _iterator3 = new FilteredIterator<FatherRel>(_iterator2, _filter3); // rule head return new NestedIterator<FatherRel, SemiOrphanRel>(_iterator3) { public ResourceIterator<SemiOrphanRel> getNextIterator(FatherRel _object) { // bind parameters from Father(f,p) _bindings.f = _object.father; return new SingletonIterator(new SemiOrphanRel(_bindings.p)); } }; }