forked from docker-java/docker-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExposedPorts.java
More file actions
45 lines (35 loc) · 1.22 KB
/
Copy pathExposedPorts.java
File metadata and controls
45 lines (35 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package com.github.dockerjava.api.model;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class ExposedPorts implements Serializable {
private static final long serialVersionUID = 1L;
private ExposedPort[] exposedPorts;
public ExposedPorts(ExposedPort... exposedPorts) {
this.exposedPorts = exposedPorts;
}
public ExposedPorts(List<ExposedPort> exposedPorts) {
this.exposedPorts = exposedPorts.toArray(new ExposedPort[exposedPorts.size()]);
}
public ExposedPort[] getExposedPorts() {
return exposedPorts;
}
@JsonCreator
public static ExposedPorts fromPrimitive(Map<String, Object> object) {
return new ExposedPorts(
object.keySet().stream().map(ExposedPort::parse).toArray(ExposedPort[]::new)
);
}
@JsonValue
public Map<String, Object> toPrimitive() {
return Stream.of(exposedPorts).collect(Collectors.toMap(
ExposedPort::toString,
__ -> new Object(),
(a, b) -> a
));
}
}