KBBuilder { public void addAll(CloseableIterator<?> it) throws KBBuilderException { Object o; try { while (it.hasNext()) { o = it.next(); if (o instanceof Rule) { this.add((Rule) o); } else if (o instanceof Atom) { this.store.add((Atom) o); } } } catch (IteratorException e) { throw new KBBuilderException(e); } catch (AtomSetException e) { throw new KBBuilderException(e); } }  KnowledgeBase build(); void setStore(Store store); void setOntology(RuleSet rules); void addAll(CloseableIterator<?> it); void add(Rule rule); void add(Rule rule, Mapper mapper); void addRules(CloseableIterator<?> it); void addRules(CloseableIterator<?> it, Mapper mapper); void add(Atom atom); void add(Atom atom, Mapper mapper); void addAtoms(CloseableIterator<?> it); void addAtoms(CloseableIterator<?> it, Mapper mapper); void setApproach(Approach approach);  }
@Test public void testAddAll() throws KBBuilderException, ParseException, AtomSetException { KBBuilder kbb = new KBBuilder(); Parser<Object> parser = new DlgpParser("[R1] p(X) :- q(X). p(a)."); kbb.addAll(parser); KnowledgeBase kb = kbb.build(); Assert.assertEquals(DlgpParser.parseRule("[R1] p(X) :- q(X)."), kb.getRule("R1")); Assert.assertTrue(kb.getFacts().contains(DlgpParser.parseAtom("p(a)."))); }