class StackDownscaleValidatorService {

    public void checkInstanceIsTheClusterManagerServerOrNot(String instancePublicIp, InstanceMetadataType metadataType) {
        if (GATEWAY.equals(metadataType) || GATEWAY_PRIMARY.equals(metadataType)) {
            String additionalIpPartForTemplate = "";
            String messageTemplate = "Downscale for the given node%s is prohibited because it " +
                    "serves as a host the Cluster Manager server";
            if (StringUtils.isNotEmpty(instancePublicIp)) {
                additionalIpPartForTemplate = " [public IP: " + instancePublicIp + "]";
            }
            throw new BadRequestException(String.format(messageTemplate, additionalIpPartForTemplate));
        }
    }

}