Element () { Element state = new Element(STATE_TAG); for (String id : myRecentExpressions.keySet()) { LinkedList<XExpression> expressions = myRecentExpressions.get(id); List<ExpressionState> states = ContainerUtil.map(expressions, ExpressionState::new); Element entryElement = new Element(EXPRESSIONS_TAG); entryElement.setAttribute(ID_ATTRIBUTE, id); for (ExpressionState expressionState : states) { entryElement.addContent(XmlSerializer.serialize(expressionState)); } state.addContent(entryElement); } return state; }