void (Element macro) { macro.setAttribute(ATTRIBUTE_NAME, myName); final ActionDescriptor[] actions = getActions(); for (ActionDescriptor action : actions) { Element actionNode = null; if (action instanceof TypedDescriptor typedDescriptor) { actionNode = new Element(ELEMENT_TYPING); actionNode.setText(typedDescriptor.getText().replaceAll(" ", "&#x20;")); actionNode.setAttribute(ATTRIBUTE_KEY_CODES, unparseKeyCodes( Couple.of(typedDescriptor.getKeyCodes(), typedDescriptor.getKeyModifiers()))); } else if (action instanceof IdActionDescriptor) { actionNode = new Element(ELEMENT_ACTION); actionNode.setAttribute(ATTRIBUTE_ID, ((IdActionDescriptor)action).getActionId()); } else if (action instanceof ShortcutActionDescription) { actionNode = new Element(ELEMENT_SHORTCUT); actionNode.setAttribute(ATTRIBUTE_TEXT, ((ShortcutActionDescription)action).getText()); } assert actionNode != null : action; macro.addContent(actionNode); } }