Skip to content

Commit ff68cfe

Browse files
committed
Merge pull request docker-java#20 from ndeloof/fluent-builder
Fluent builder
2 parents a9134be + b7499a4 commit ff68cfe

File tree

3 files changed

+91
-27
lines changed

3 files changed

+91
-27
lines changed

src/main/java/com/kpelykh/docker/client/model/CommitConfig.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,35 @@ public String getRun() {
5353
return run;
5454
}
5555

56+
public CommitConfig setRepo(String repo) {
57+
this.repo = repo;
58+
return this;
59+
}
60+
61+
public CommitConfig setTag(String tag) {
62+
this.tag = tag;
63+
return this;
64+
}
65+
66+
public CommitConfig setMessage(String message) {
67+
this.message = message;
68+
return this;
69+
}
70+
71+
public CommitConfig setAuthor(String author) {
72+
this.author = author;
73+
return this;
74+
}
75+
76+
public CommitConfig setRun(String run) {
77+
this.run = run;
78+
return this;
79+
}
80+
81+
public CommitConfig(String container) {
82+
this.container = container;
83+
}
84+
5685
private CommitConfig(Builder b) {
5786
this.container = b.container;
5887
this.repo = b.repo;

src/main/java/com/kpelykh/docker/client/model/ContainerConfig.java

Lines changed: 44 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -52,172 +52,194 @@ public String getDomainName() {
5252

5353
public String getWorkingDir() { return workingDir; }
5454

55-
public void setWorkingDir(String workingDir) {
55+
public ContainerConfig setWorkingDir(String workingDir) {
5656
this.workingDir = workingDir;
57+
return this;
5758
}
5859

5960
public boolean isPrivileged() {
6061
return privileged;
6162
}
6263

63-
public void setPrivileged(boolean privileged) {
64+
public ContainerConfig setPrivileged(boolean privileged) {
6465
this.privileged = privileged;
66+
return this;
6567
}
6668

6769
public String getHostName() {
6870
return hostName;
6971
}
7072

71-
public void setNetworkDisabled(boolean networkDisabled) {
73+
public ContainerConfig setNetworkDisabled(boolean networkDisabled) {
7274
this.networkDisabled = networkDisabled;
75+
return this;
7376
}
7477

75-
public void setHostName(String hostName) {
78+
public ContainerConfig setHostName(String hostName) {
7679
this.hostName = hostName;
80+
return this;
7781
}
7882

7983
public String[] getPortSpecs() {
8084
return portSpecs;
8185
}
8286

83-
public void setPortSpecs(String[] portSpecs) {
87+
public ContainerConfig setPortSpecs(String[] portSpecs) {
8488
this.portSpecs = portSpecs;
89+
return this;
8590
}
8691

8792
public String getUser() {
8893
return user;
8994
}
9095

91-
public void setUser(String user) {
96+
public ContainerConfig setUser(String user) {
9297
this.user = user;
98+
return this;
9399
}
94100

95101
public boolean isTty() {
96102
return tty;
97103
}
98104

99-
public void setTty(boolean tty) {
105+
public ContainerConfig setTty(boolean tty) {
100106
this.tty = tty;
107+
return this;
101108
}
102109

103110
public boolean isStdinOpen() {
104111
return stdinOpen;
105112
}
106113

107-
public void setStdinOpen(boolean stdinOpen) {
114+
public ContainerConfig setStdinOpen(boolean stdinOpen) {
108115
this.stdinOpen = stdinOpen;
116+
return this;
109117
}
110118

111119
public boolean isStdInOnce() {
112120
return stdInOnce;
113121
}
114122

115-
public void setStdInOnce(boolean stdInOnce) {
123+
public ContainerConfig setStdInOnce(boolean stdInOnce) {
116124
this.stdInOnce = stdInOnce;
125+
return this;
117126
}
118127

119128
public long getMemoryLimit() {
120129
return memoryLimit;
121130
}
122131

123-
public void setMemoryLimit(long memoryLimit) {
132+
public ContainerConfig setMemoryLimit(long memoryLimit) {
124133
this.memoryLimit = memoryLimit;
134+
return this;
125135
}
126136

127137
public long getMemorySwap() {
128138
return memorySwap;
129139
}
130140

131-
public void setMemorySwap(long memorySwap) {
141+
public ContainerConfig setMemorySwap(long memorySwap) {
132142
this.memorySwap = memorySwap;
143+
return this;
133144
}
134145

135146
public int getCpuShares() {
136147
return cpuShares;
137148
}
138149

139-
public void setCpuShares(int cpuShares) {
150+
public ContainerConfig setCpuShares(int cpuShares) {
140151
this.cpuShares = cpuShares;
152+
return this;
141153
}
142154

143155
public boolean isAttachStdin() {
144156
return attachStdin;
145157
}
146158

147-
public void setAttachStdin(boolean attachStdin) {
159+
public ContainerConfig setAttachStdin(boolean attachStdin) {
148160
this.attachStdin = attachStdin;
161+
return this;
149162
}
150163

151164
public boolean isAttachStdout() {
152165
return attachStdout;
153166
}
154167

155-
public void setAttachStdout(boolean attachStdout) {
168+
public ContainerConfig setAttachStdout(boolean attachStdout) {
156169
this.attachStdout = attachStdout;
170+
return this;
157171
}
158172

159173
public boolean isAttachStderr() {
160174
return attachStderr;
161175
}
162176

163-
public void setAttachStderr(boolean attachStderr) {
177+
public ContainerConfig setAttachStderr(boolean attachStderr) {
164178
this.attachStderr = attachStderr;
179+
return this;
165180
}
166181

167182
public String[] getEnv() {
168183
return env;
169184
}
170185

171-
public void setEnv(String[] env) {
186+
public ContainerConfig setEnv(String[] env) {
172187
this.env = env;
188+
return this;
173189
}
174190

175191
public String[] getCmd() {
176192
return cmd;
177193
}
178194

179-
public void setCmd(String[] cmd) {
195+
public ContainerConfig setCmd(String[] cmd) {
180196
this.cmd = cmd;
197+
return this;
181198
}
182199

183200
public String[] getDns() {
184201
return dns;
185202
}
186203

187-
public void setDns(String[] dns) {
204+
public ContainerConfig setDns(String[] dns) {
188205
this.dns = dns;
206+
return this;
189207
}
190208

191209
public String getImage() {
192210
return image;
193211
}
194212

195-
public void setImage(String image) {
213+
public ContainerConfig setImage(String image) {
196214
this.image = image;
215+
return this;
197216
}
198217

199218
public Object getVolumes() {
200219
return volumes;
201220
}
202221

203-
public void setVolumes(Object volumes) {
222+
public ContainerConfig setVolumes(Object volumes) {
204223
this.volumes = volumes;
224+
return this;
205225
}
206226

207227
public String getVolumesFrom() {
208228
return volumesFrom;
209229
}
210230

211-
public void setVolumesFrom(String volumesFrom) {
231+
public ContainerConfig setVolumesFrom(String volumesFrom) {
212232
this.volumesFrom = volumesFrom;
233+
return this;
213234
}
214235

215236
public String[] getEntrypoint() {
216237
return entrypoint;
217238
}
218239

219-
public void setEntrypoint(String[] entrypoint) {
240+
public ContainerConfig setEntrypoint(String[] entrypoint) {
220241
this.entrypoint = entrypoint;
242+
return this;
221243
}
222244

223245
@Override

src/main/java/com/kpelykh/docker/client/model/HostConfig.java

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,27 @@ public String[] getBinds() {
2626
return binds;
2727
}
2828

29-
public void setBinds(String[] binds) {
29+
public HostConfig setBinds(String[] binds) {
3030
this.binds = binds;
31+
return this;
3132
}
3233

3334
public String getContainerIDFile() {
3435
return containerIDFile;
3536
}
3637

37-
public void setContainerIDFile(String containerIDFile) {
38+
public HostConfig setContainerIDFile(String containerIDFile) {
3839
this.containerIDFile = containerIDFile;
40+
return this;
3941
}
4042

4143
public LxcConf[] getLxcConf() {
4244
return lxcConf;
4345
}
4446

45-
public void setLxcConf(LxcConf[] lxcConf) {
47+
public HostConfig setLxcConf(LxcConf[] lxcConf) {
4648
this.lxcConf = lxcConf;
49+
return this;
4750
}
4851

4952
public class LxcConf {
@@ -53,20 +56,30 @@ public class LxcConf {
5356
@JsonProperty("Value")
5457
public String value;
5558

59+
public LxcConf(String key, String value) {
60+
this.key = key;
61+
this.value = value;
62+
}
63+
64+
public LxcConf() {
65+
}
66+
5667
public String getKey() {
5768
return key;
5869
}
5970

60-
public void setKey(String key) {
71+
public LxcConf setKey(String key) {
6172
this.key = key;
73+
return this;
6274
}
6375

6476
public String getValue() {
6577
return value;
6678
}
6779

68-
public void setValue(String value) {
80+
public LxcConf setValue(String value) {
6981
this.value = value;
82+
return this;
7083
}
7184

7285
}

0 commit comments

Comments
 (0)