Element (@NotNull ArrangementMatchRule rule) { Element matcherElement = myMatcherSerializer.serialize(rule.getMatcher()); if (matcherElement == null) { return null; } Element result = new Element(RULE_ELEMENT_NAME); result.addContent(new Element(MATCHER_ELEMENT_NAME).addContent(matcherElement)); if (rule.getOrderType() != ArrangementMatchRule.DEFAULT_ORDER_TYPE) { result.addContent(new Element(ORDER_TYPE_ELEMENT_NAME).setText(rule.getOrderType().getId())); } return result; }