WorkspaceEntity (@NotNull MutableEntityStorage diff, @NotNull EntitySource source, @NotNull Project project) { WorkspaceEntity existingEntity = getExistingEntity(diff); if (existingEntity != null) return existingEntity; S state = this.getState(); String xmlTag = ""; if (state != null) { xmlTag = JDOMUtil.write(XmlSerializer.serialize(state)); } List<PackagingElementEntity> children = new ArrayList<>(); if (this instanceof CompositePackagingElement<?>) { children.addAll( ContainerUtil.map(((CompositePackagingElement<Object>)this).getChildren(), o -> (PackagingElementEntity)o.getOrAddEntity(diff, source, project)) ); } CustomPackagingElementEntity addedEntity = diff.addEntity(CustomPackagingElementEntity.create(this.getType().getId(), xmlTag, source, builder -> { builder.setChildren(children); return Unit.INSTANCE; })); diff.getMutableExternalMapping("intellij.artifacts.packaging.elements").addMapping(addedEntity, this); return addedEntity; }