protected void loadQuery(Element element, DataLoader loader) { Element queryEl = element.element("query"); if (queryEl != null) { loader.setQuery(loadQueryText(queryEl)); Element conditionEl = queryEl.element("condition"); if (conditionEl != null) { if (!conditionEl.elements().isEmpty()) { if (conditionEl.elements().size() == 1) { Condition condition = conditionXmlLoader.fromXml(conditionEl.elements().get(0)); loader.setCondition(condition); } else { throw new IllegalStateException("'condition' element must have exactly one nested element"); } } } } }