class ClouderaHostGroupAssociationBuilder {

    Map<String, List<Map<String, String>>> buildHostGroupAssociations(Map<HostGroup, List<InstanceMetaData>> instanceMetaDataByHostGroup) {
        Map<String, List<Map<String, String>>> hostGroupMappings = new HashMap<>();
        LOGGER.debug("Computing host - hostGroup mappings based on hostGroup - instanceGroup associations");
        for (Entry<HostGroup, List<InstanceMetaData>> hostGroupListEntry : instanceMetaDataByHostGroup.entrySet()) {
            List<Map<String, String>> hostInfoForHostGroup = buildHostGroupAssociation(hostGroupListEntry.getValue());
            hostGroupMappings.put(hostGroupListEntry.getKey().getName(), hostInfoForHostGroup);
        }
        LOGGER.debug("Computed host-hostGroup associations: {}", hostGroupMappings);
        return hostGroupMappings;
    }

}