class StackConfigTypeValidator implements TopologyValidator {

  @Override
  public void validate(ClusterTopology topology) throws InvalidTopologyException {

    // get the config types form the request
    Set<String> incomingConfigTypes = new HashSet<>(topology.getConfiguration().getAllConfigTypes());

    if (incomingConfigTypes.isEmpty()) {
      LOGGER.debug("No config types to be checked.");
      return;
    }

    Set<String> stackConfigTypes = new HashSet<>(topology.getBlueprint().getStack().getConfiguration().getAllConfigTypes());

    // remove all "valid" config types from the incoming set
    incomingConfigTypes.removeAll(stackConfigTypes);

    if (!incomingConfigTypes.isEmpty()) {
      // there are config types in the request that are not in the stack
      String message = String.format("The following config types are not defined in the stack: %s ", incomingConfigTypes);
      LOGGER.error(message);
      throw new InvalidTopologyException(message);
    }
  }

  public  StackConfigTypeValidator();

}