class MetadataEntityConverter {

    public static Map<String, String> convert(List<MetadataEntity> entities) {
        Map<FireCloudClass, FireCloudData> content = new EnumMap<>(FireCloudClass.class);
        entities.forEach(entity -> {
            FireCloudClass fireCloudClass = entity.getClassEntity().getFireCloudClassName();
            Assert.notNull(fireCloudClass, "Fire Cloud class must be specified.");
            FireCloudData dataContent = content.computeIfAbsent(fireCloudClass, key ->
                    new FireCloudData(fireCloudClass, entity.getData()));
            dataContent.put(entity);
        });
        Map<String, String> result = new HashMap<>();
        content.forEach(((fireCloudClass, fireCloudData) -> {
            result.put(fireCloudClass.getFileName(), fireCloudData.getContent());
            if (fireCloudData.isSet()) {
                result.put(fireCloudClass.getMembershipFileName(), fireCloudData.getMembershipContent());
            }
        }));
        return result;
    }

    private  MetadataEntityConverter();

}