forked from docker-java/docker-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathListContainersCmdImpl.java
More file actions
156 lines (127 loc) · 4.33 KB
/
Copy pathListContainersCmdImpl.java
File metadata and controls
156 lines (127 loc) · 4.33 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
package com.github.dockerjava.core.command;
import com.github.dockerjava.api.command.ListContainersCmd;
import com.github.dockerjava.api.command.ListContainersSpec;
import com.github.dockerjava.api.model.Container;
import com.github.dockerjava.core.util.FiltersBuilder;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* List containers.
*/
public class ListContainersCmdImpl extends AbstrDockerCmd<ListContainersCmd, List<Container>> implements
ListContainersCmd {
private ListContainersSpec spec;
private final FiltersBuilder filters = new FiltersBuilder();
public ListContainersCmdImpl(ListContainersCmd.Exec exec) {
this(exec, ListContainersSpec.builder().build());
}
ListContainersCmdImpl(ListContainersCmd.Exec exec, ListContainersSpec spec) {
super(exec);
this.spec = spec;
}
@Override
public Integer getLimit() {
return spec.getLimit();
}
@Override
public Boolean hasShowSizeEnabled() {
return spec.hasShowSizeEnabled();
}
@Override
public Boolean hasShowAllEnabled() {
return spec.hasShowAllEnabled();
}
@Override
public String getSinceId() {
return spec.getSinceId();
}
@Override
public String getBeforeId() {
return spec.getBeforeId();
}
@Override
public Map<String, List<String>> getFilters() {
return spec.getFilters();
}
@Override
public ListContainersCmd withShowAll(Boolean showAll) {
this.spec = spec.withHasShowAllEnabled(showAll);
return this;
}
@Override
public ListContainersCmd withShowSize(Boolean showSize) {
this.spec = spec.withHasShowSizeEnabled(showSize);
return this;
}
@Override
public ListContainersCmd withLimit(Integer limit) {
checkNotNull(limit, "limit was not specified");
checkArgument(limit > 0, "limit must be greater 0");
this.spec = spec.withLimit(limit);
return this;
}
@Override
public ListContainersCmd withSince(String since) {
checkNotNull(since, "since was not specified");
this.spec = spec.withSinceId(since);
return this;
}
@Override
public ListContainersCmd withBefore(String before) {
checkNotNull(before, "before was not specified");
this.spec = spec.withBeforeId(before);
return this;
}
@Override
public ListContainersCmd withNameFilter(Collection<String> name) {
return withFilter("name", name);
}
@Override
public ListContainersCmd withIdFilter(Collection<String> id) {
return withFilter("id", id);
}
@Override
public ListContainersCmd withAncestorFilter(Collection<String> ancestor) {
return withFilter("ancestor", ancestor);
}
@Override
public ListContainersCmd withVolumeFilter(Collection<String> volume) {
return withFilter("volume", volume);
}
@Override
public ListContainersCmd withNetworkFilter(Collection<String> network) {
return withFilter("network", network);
}
@Override
public ListContainersCmd withLabelFilter(Collection<String> labels) {
return withFilter("label", labels);
}
@Override
public ListContainersCmd withStatusFilter(Collection<String> status) {
return withFilter("status", status);
}
@Override
public ListContainersCmd withLabelFilter(Map<String, String> labels) {
checkNotNull(labels, "labels was not specified");
this.filters.withLabels(labels);
this.spec = spec.withFilters(this.filters.build());
return this;
}
@Override
public ListContainersCmd withExitedFilter(Integer exited) {
checkNotNull(exited, "exited was not specified");
this.filters.withFilter("exited", exited.toString());
this.spec = spec.withFilters(this.filters.build());
return this;
}
@Override
public ListContainersCmd withFilter(String filterName, Collection<String> filterValues) {
checkNotNull(filterValues, filterName + " was not specified");
this.filters.withFilter(filterName, filterValues);
this.spec = spec.withFilters(this.filters.build());
return this;
}
}