class IspModelingUtils {

  @VisibleForTesting
  static Map<Long, IspModel> combineIspConfigurations(
      Map<String, Configuration> configurations,
      List<IspConfiguration> ispConfigurations,
      Warnings warnings) {
    Map<Long, IspModel> asnToIspInfos = new HashMap<>();

    for (IspConfiguration ispConfiguration : ispConfigurations) {
      Map<String, Set<String>> interfaceSetByNodes =
          ispConfiguration.getBorderInterfaces().stream()
              .map(BorderInterfaceInfo::getBorderInterface)
              .collect(
                  Collectors.groupingBy(
                      nodeInterfacePair -> nodeInterfacePair.getHostname().toLowerCase(),
                      Collectors.mapping(NodeInterfacePair::getInterface, Collectors.toSet())));

      for (Entry<String, Set<String>> remoteNodeAndInterfaces : interfaceSetByNodes.entrySet()) {
        Configuration remoteCfg = configurations.get(remoteNodeAndInterfaces.getKey());
        if (remoteCfg == null) {
          warnings.redFlag(
              String.format(
                  "ISP Modeling: Non-existent border node %s specified in ISP configuration",
                  remoteNodeAndInterfaces.getKey()));
          continue;
        }
        populateIspModels(
            remoteCfg,
            remoteNodeAndInterfaces.getValue(),
            ispConfiguration.getFilter().getOnlyRemoteIps(),
            ispConfiguration.getFilter().getOnlyRemoteAsns(),
            ispConfiguration.getIspNodeInfos(),
            asnToIspInfos,
            warnings);
      }
    }

    return asnToIspInfos;
  }

  private  IspModelingUtils();

}