/** * Convert a map generated by the toMap() method back to a DockerPortMapping * * @param map * @return */ public static List<DockerPortMapping> fromMap(Map<String, List<Map<String, String>>> map) { return map.entrySet().stream() .map((e) -> fromMap(e)) .filter((m) -> m != null) .collect(Collectors.toList()); }
/** * Process port binding properties * * @param containerState * @param networkSettings */ private static void mapPortBindingProperties(ContainerState containerState, Map<String, Object> networkSettings) { if (networkSettings == null) { return; } Map<String, List<Map<String, String>>> portMap = getMap(networkSettings, DOCKER_CONTAINER_NETWORK_SETTINGS_PORTS_PROP_NAME); if (containerState.ports == null) { containerState.ports = new ArrayList<PortBinding>(); } if (portMap != null) { List<DockerPortMapping> portMappings = DockerPortMapping.fromMap(portMap); containerState.ports = portMappings.stream() .map((m) -> PortBinding.fromDockerPortMapping(m)) .collect(Collectors.toList()); } }