@VisibleForTesting
  static ImmutableSet<Port> portMapToSet(@Nullable Map<String, Map<String, String>> portMap)
      throws BadContainerConfigurationFormatException {
    if (portMap == null) {
      return ImmutableSet.of();
    }
    ImmutableSet.Builder<Port> ports = new ImmutableSet.Builder<>();
    for (Map.Entry<String, Map<String, String>> entry : portMap.entrySet()) {
      String port = entry.getKey();
      Matcher matcher = PORT_PATTERN.matcher(port);
      if (!matcher.matches()) {
        throw new BadContainerConfigurationFormatException(
            "Invalid port configuration: '" + port + "'.");
      }

      int portNumber = Integer.parseInt(matcher.group("portNum"));
      String protocol = matcher.group("protocol");
      ports.add(Port.parseProtocol(portNumber, protocol));
    }
    return ports.build();
  }
Converts a map of exposed ports as strings to a set of {@link Port}s (e.g. {@code
{"1000/tcp":{}}} -> {@code Port(1000, Protocol.TCP)}).

@param portMap the map to convert
@return a set of {@link Port}s
jib-core/src/main/java/com/google/cloud/tools/jib/image/json/JsonToImageTranslator.java