class IspModelingUtils {

  @VisibleForTesting
  static boolean isValidBgpPeerConfig(
      @Nonnull BgpPeerConfig bgpPeerConfig,
      @Nonnull Set<Ip> localIps,
      @Nonnull Set<Ip> remoteIps,
      @Nonnull LongSpace remoteAsns) {
    boolean commonCriteria =
        Objects.nonNull(bgpPeerConfig.getLocalIp())
            && Objects.nonNull(bgpPeerConfig.getLocalAs())
            && !bgpPeerConfig.getRemoteAsns().equals(LongSpace.of(bgpPeerConfig.getLocalAs()))
            && localIps.contains(bgpPeerConfig.getLocalIp())
            && !remoteAsns.intersection(bgpPeerConfig.getRemoteAsns()).isEmpty();
    if (!commonCriteria) {
      return false;
    }
    if (bgpPeerConfig instanceof BgpActivePeerConfig) {
      BgpActivePeerConfig activePeerConfig = (BgpActivePeerConfig) bgpPeerConfig;
      return Objects.nonNull(activePeerConfig.getPeerAddress())
          && (remoteIps.isEmpty() || remoteIps.contains(activePeerConfig.getPeerAddress()));
    } else if (bgpPeerConfig instanceof BgpUnnumberedPeerConfig) {
      // peer interface is always non-null, so need to check
      return true;
    } else {
      // passive peers, in case passed into this function, are declared invalid
      return false;
    }
  }

  private  IspModelingUtils();

}