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
151 lines (121 loc) · 3.92 KB
/
Copy pathListContainersCmdImpl.java
File metadata and controls
151 lines (121 loc) · 3.92 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
package com.github.dockerjava.core.command;
import com.github.dockerjava.api.command.ListContainersCmd;
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 java.util.Objects;
import static com.google.common.base.Preconditions.checkArgument;
/**
* List containers.
*/
public class ListContainersCmdImpl extends AbstrDockerCmd<ListContainersCmd, List<Container>> implements
ListContainersCmd {
private Integer limit = -1;
private Boolean showSize, showAll = false;
private String sinceId, beforeId;
private FiltersBuilder filters = new FiltersBuilder();
public ListContainersCmdImpl(ListContainersCmd.Exec exec) {
super(exec);
}
@Override
public Integer getLimit() {
return limit;
}
@Override
public Boolean hasShowSizeEnabled() {
return showSize;
}
@Override
public Boolean hasShowAllEnabled() {
return showAll;
}
@Override
public String getSinceId() {
return sinceId;
}
@Override
public String getBeforeId() {
return beforeId;
}
@Override
public Map<String, List<String>> getFilters() {
return filters.build();
}
@Override
public ListContainersCmd withShowAll(Boolean showAll) {
this.showAll = showAll;
return this;
}
@Override
public ListContainersCmd withShowSize(Boolean showSize) {
this.showSize = showSize;
return this;
}
@Override
public ListContainersCmd withLimit(Integer limit) {
Objects.requireNonNull(limit, "limit was not specified");
checkArgument(limit > 0, "limit must be greater 0");
this.limit = limit;
return this;
}
@Override
public ListContainersCmd withSince(String since) {
this.sinceId = Objects.requireNonNull(since, "since was not specified");
return this;
}
@Override
public ListContainersCmd withBefore(String before) {
this.beforeId = Objects.requireNonNull(before, "before was not specified");
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 withLabelFilter(Map<String, String> labels) {
Objects.requireNonNull(labels, "labels was not specified");
this.filters.withLabels(labels);
return this;
}
@Override
public ListContainersCmd withExitedFilter(Integer exited) {
Objects.requireNonNull(exited, "exited was not specified");
this.filters.withFilter("exited", exited.toString());
return this;
}
@Override
public ListContainersCmd withFilter(String filterName, Collection<String> filterValues) {
Objects.requireNonNull(filterValues, filterName + " was not specified");
this.filters.withFilter(filterName, filterValues);
return this;
}
@Override
public ListContainersCmd withStatusFilter(Collection<String> status) {
Objects.requireNonNull(status, "status was not specified");
this.filters.withFilter("status", status);
return this;
}
}