class CmTemplateProcessor implements BlueprintTextProcessor {

    @Override
    public GatewayRecommendation recommendGateway() {
        Map<String, InstanceCount> instanceCounts = getCardinalityByHostGroup();

        for (String group : List.of("gateway", "master")) {
            InstanceCount count = instanceCounts.get(group);
            if (InstanceCount.EXACTLY_ONE.equals(count)) {
                return new GatewayRecommendation(Set.of(group));
            }
        }

        return instanceCounts.entrySet().stream()
                .filter(e -> e.getValue().getMinimumCount() <= 1)
                .map(Map.Entry::getKey)
                .sorted()
                .findFirst()
                .map(hostGroup -> new GatewayRecommendation(Set.of(hostGroup)))
                .orElseGet(() -> new GatewayRecommendation(Set.of()));
    }

    public  CmTemplateProcessor(@Nonnull String cmTemplateText);

}