Element (@NotNull FileTypeWithDescriptor ftd) { Element root = new Element(ELEMENT_FILETYPE); AbstractFileType fileType = (AbstractFileType)ftd.fileType; root.setAttribute("binary", String.valueOf(fileType.isBinary())); if (!Strings.isEmpty(fileType.getDefaultExtension())) { root.setAttribute("default_extension", fileType.getDefaultExtension()); } root.setAttribute(ATTRIBUTE_DESCRIPTION, fileType.getDescription()); root.setAttribute(ATTRIBUTE_NAME, fileType.getName()); fileType.writeExternal(root); Element map = new Element(ELEMENT_EXTENSION_MAP); writeExtensionsMap(map, ftd, false); if (!map.getChildren().isEmpty()) { root.addContent(map); } return root; }