Skip to content

Commit 561f9d0

Browse files
author
Marcus Linke
committed
Added null check annotations and removed withX() methods
1 parent ae29bf7 commit 561f9d0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+418
-403
lines changed

src/main/java/com/github/dockerjava/api/command/AttachContainerCmd.java

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
import java.io.InputStream;
44

5+
import javax.annotation.CheckForNull;
6+
import javax.annotation.Nonnull;
7+
58
import com.github.dockerjava.api.DockerClient;
69
import com.github.dockerjava.api.model.Frame;
710

@@ -22,24 +25,25 @@
2225
*/
2326
public interface AttachContainerCmd extends AsyncDockerCmd<AttachContainerCmd, Frame> {
2427

28+
@CheckForNull
2529
public String getContainerId();
2630

31+
@CheckForNull
2732
public Boolean hasLogsEnabled();
2833

34+
@CheckForNull
2935
public Boolean hasFollowStreamEnabled();
3036

37+
@CheckForNull
3138
public Boolean hasTimestampsEnabled();
3239

40+
@CheckForNull
3341
public Boolean hasStdoutEnabled();
3442

43+
@CheckForNull
3544
public Boolean hasStderrEnabled();
3645

37-
public AttachContainerCmd withContainerId(String containerId);
38-
39-
/**
40-
* See {@link #withFollowStream(Boolean)}
41-
*/
42-
public AttachContainerCmd withFollowStream();
46+
public AttachContainerCmd withContainerId(@Nonnull String containerId);
4347

4448
/**
4549
* Following the stream means the resulting {@link InputStream} returned by {@link #exec()} reads infinitely. So a
@@ -50,18 +54,12 @@ public interface AttachContainerCmd extends AsyncDockerCmd<AttachContainerCmd, F
5054

5155
public AttachContainerCmd withTimestamps(Boolean timestamps);
5256

53-
public AttachContainerCmd withStdOut();
54-
5557
public AttachContainerCmd withStdOut(Boolean stdout);
5658

57-
public AttachContainerCmd withStdErr();
58-
5959
public AttachContainerCmd withStdErr(Boolean stderr);
6060

6161
public AttachContainerCmd withLogs(Boolean logs);
6262

63-
public AttachContainerCmd withLogs();
64-
6563
public static interface Exec extends DockerCmdAsyncExec<AttachContainerCmd, Frame> {
6664
}
6765

src/main/java/com/github/dockerjava/api/command/AuthCmd.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package com.github.dockerjava.api.command;
22

3+
import javax.annotation.CheckForNull;
4+
import javax.annotation.Nonnull;
5+
36
import com.github.dockerjava.api.UnauthorizedException;
47
import com.github.dockerjava.api.model.AuthConfig;
58
import com.github.dockerjava.api.model.AuthResponse;
@@ -11,9 +14,10 @@
1114
*/
1215
public interface AuthCmd extends SyncDockerCmd<AuthResponse> {
1316

17+
@CheckForNull
1418
public AuthConfig getAuthConfig();
1519

16-
public AuthCmd withAuthConfig(AuthConfig authConfig);
20+
public AuthCmd withAuthConfig(@Nonnull AuthConfig authConfig);
1721

1822
/**
1923
* @return The status. Based on it's value you may mean you need to authorise your account, e.g.:

src/main/java/com/github/dockerjava/api/command/BuildImageCmd.java

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import com.github.dockerjava.api.model.BuildResponseItem;
55

66
import javax.annotation.CheckForNull;
7+
import javax.annotation.Nonnull;
8+
79
import java.io.File;
810
import java.io.InputStream;
911
import java.net.URI;
@@ -20,8 +22,10 @@ public interface BuildImageCmd extends AsyncDockerCmd<BuildImageCmd, BuildRespon
2022

2123
// lib specific
2224

25+
@CheckForNull
2326
public InputStream getTarInputStream();
2427

28+
@CheckForNull
2529
public AuthConfigurations getBuildAuthConfigs();
2630

2731
// getters
@@ -41,29 +45,31 @@ public interface BuildImageCmd extends AsyncDockerCmd<BuildImageCmd, BuildRespon
4145
/**
4246
* "nocache" in API
4347
*/
48+
@CheckForNull
4449
public Boolean hasNoCacheEnabled();
4550

4651
/**
4752
* "rm" in API
4853
*/
54+
@CheckForNull
4955
public Boolean hasRemoveEnabled();
5056

5157
/**
5258
* "forcerm" in API
5359
*/
54-
public boolean isForcerm();
55-
5660
@CheckForNull
57-
public Boolean getForcerm();
61+
public Boolean isForcerm();
5862

5963
/**
6064
* "q" in API
6165
*/
66+
@CheckForNull
6267
public Boolean isQuiet();
6368

6469
/**
6570
* "pull" in API
6671
*/
72+
@CheckForNull
6773
public Boolean hasPullEnabled();
6874

6975
@CheckForNull
@@ -91,24 +97,14 @@ public interface BuildImageCmd extends AsyncDockerCmd<BuildImageCmd, BuildRespon
9197

9298
public BuildImageCmd withDockerfile(File dockerfile);
9399

94-
public BuildImageCmd withNoCache();
95-
96100
public BuildImageCmd withNoCache(Boolean noCache);
97101

98-
public BuildImageCmd withRemove();
99-
100102
public BuildImageCmd withRemove(Boolean rm);
101103

102-
public BuildImageCmd withForcerm();
103-
104104
public BuildImageCmd withForcerm(Boolean forcerm);
105105

106-
public BuildImageCmd withQuiet();
107-
108106
public BuildImageCmd withQuiet(Boolean quiet);
109107

110-
public BuildImageCmd withPull();
111-
112108
public BuildImageCmd withPull(Boolean pull);
113109

114110
public BuildImageCmd withMemory(Long memory);
@@ -123,7 +119,7 @@ public interface BuildImageCmd extends AsyncDockerCmd<BuildImageCmd, BuildRespon
123119

124120
public BuildImageCmd withBuildAuthConfigs(AuthConfigurations authConfig);
125121

126-
public BuildImageCmd withTarInputStream(InputStream tarInputStream);
122+
public BuildImageCmd withTarInputStream(@Nonnull InputStream tarInputStream);
127123

128124
public static interface Exec extends DockerCmdAsyncExec<BuildImageCmd, BuildResponseItem> {
129125
}
Lines changed: 52 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package com.github.dockerjava.api.command;
22

3+
import javax.annotation.CheckForNull;
4+
import javax.annotation.Nonnull;
5+
36
import com.github.dockerjava.api.NotFoundException;
47
import com.github.dockerjava.api.model.ExposedPorts;
58
import com.github.dockerjava.api.model.Volumes;
@@ -11,96 +14,104 @@
1114
*/
1215
public interface CommitCmd extends SyncDockerCmd<String> {
1316

17+
@CheckForNull
18+
public String getAuthor();
19+
20+
@CheckForNull
1421
public String getContainerId();
1522

16-
public CommitCmd withContainerId(String containerId);
23+
@CheckForNull
24+
public String[] getEnv();
1725

18-
public String getRepository();
26+
@CheckForNull
27+
public ExposedPorts getExposedPorts();
1928

20-
public String getTag();
29+
@CheckForNull
30+
public String getHostname();
2131

32+
@CheckForNull
33+
public Integer getMemory();
34+
35+
@CheckForNull
36+
public Integer getMemorySwap();
37+
38+
@CheckForNull
2239
public String getMessage();
2340

24-
public String getAuthor();
41+
@CheckForNull
42+
public String[] getPortSpecs();
2543

26-
public Boolean hasPauseEnabled();
44+
@CheckForNull
45+
public String getRepository();
2746

28-
public CommitCmd withAttachStderr(Boolean attachStderr);
47+
@CheckForNull
48+
public String getTag();
2949

30-
public CommitCmd withAttachStderr();
50+
@CheckForNull
51+
public String getUser();
3152

32-
public CommitCmd withAttachStdin(Boolean attachStdin);
53+
@CheckForNull
54+
public Volumes getVolumes();
3355

34-
public CommitCmd withAttachStdin();
56+
@CheckForNull
57+
public String getWorkingDir();
3558

36-
public CommitCmd withAttachStdout(Boolean attachStdout);
59+
@CheckForNull
60+
public Boolean hasPauseEnabled();
3761

38-
public CommitCmd withAttachStdout();
62+
@CheckForNull
63+
public Boolean isOpenStdin();
3964

40-
public CommitCmd withCmd(String... cmd);
65+
@CheckForNull
66+
public Boolean isStdinOnce();
4167

42-
public CommitCmd withDisableNetwork(Boolean disableNetwork);
68+
@CheckForNull
69+
public Boolean isTty();
4370

44-
public CommitCmd withAuthor(String author);
71+
public CommitCmd withAttachStderr(Boolean attachStderr);
4572

46-
public CommitCmd withMessage(String message);
73+
public CommitCmd withAttachStdin(Boolean attachStdin);
4774

48-
public CommitCmd withTag(String tag);
75+
public CommitCmd withAttachStdout(Boolean attachStdout);
4976

50-
public CommitCmd withRepository(String repository);
77+
public CommitCmd withAuthor(String author);
5178

52-
public CommitCmd withPause(Boolean pause);
79+
public CommitCmd withCmd(String... cmd);
5380

54-
public String[] getEnv();
81+
public CommitCmd withContainerId(@Nonnull String containerId);
5582

56-
public CommitCmd withEnv(String... env);
83+
public CommitCmd withDisableNetwork(Boolean disableNetwork);
5784

58-
public ExposedPorts getExposedPorts();
85+
public CommitCmd withEnv(String... env);
5986

6087
public CommitCmd withExposedPorts(ExposedPorts exposedPorts);
6188

62-
public String getHostname();
63-
6489
public CommitCmd withHostname(String hostname);
6590

66-
public Integer getMemory();
67-
6891
public CommitCmd withMemory(Integer memory);
6992

70-
public Integer getMemorySwap();
71-
7293
public CommitCmd withMemorySwap(Integer memorySwap);
7394

74-
public Boolean isOpenStdin();
95+
public CommitCmd withMessage(String message);
7596

7697
public CommitCmd withOpenStdin(Boolean openStdin);
7798

78-
public String[] getPortSpecs();
99+
public CommitCmd withPause(Boolean pause);
79100

80101
public CommitCmd withPortSpecs(String... portSpecs);
81102

82-
public Boolean isStdinOnce();
103+
public CommitCmd withRepository(String repository);
83104

84105
public CommitCmd withStdinOnce(Boolean stdinOnce);
85106

86-
public CommitCmd withStdinOnce();
87-
88-
public Boolean isTty();
107+
public CommitCmd withTag(String tag);
89108

90109
public CommitCmd withTty(Boolean tty);
91110

92-
public CommitCmd withTty();
93-
94-
public String getUser();
95-
96111
public CommitCmd withUser(String user);
97112

98-
public Volumes getVolumes();
99-
100113
public CommitCmd withVolumes(Volumes volumes);
101114

102-
public String getWorkingDir();
103-
104115
public CommitCmd withWorkingDir(String workingDir);
105116

106117
/**
@@ -112,5 +123,4 @@ public interface CommitCmd extends SyncDockerCmd<String> {
112123

113124
public static interface Exec extends DockerCmdSyncExec<CommitCmd, String> {
114125
}
115-
116126
}

src/main/java/com/github/dockerjava/api/command/ContainerDiffCmd.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,20 @@
22

33
import java.util.List;
44

5+
import javax.annotation.CheckForNull;
6+
import javax.annotation.Nonnull;
7+
58
import com.github.dockerjava.api.DockerException;
69
import com.github.dockerjava.api.InternalServerErrorException;
710
import com.github.dockerjava.api.NotFoundException;
811
import com.github.dockerjava.api.model.ChangeLog;
912

1013
public interface ContainerDiffCmd extends SyncDockerCmd<List<ChangeLog>> {
1114

15+
@CheckForNull
1216
public String getContainerId();
1317

14-
public ContainerDiffCmd withContainerId(String containerId);
18+
public ContainerDiffCmd withContainerId(@Nonnull String containerId);
1519

1620
@Override
1721
public String toString();

src/main/java/com/github/dockerjava/api/command/CopyFileFromContainerCmd.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,28 @@
22

33
import java.io.InputStream;
44

5+
import javax.annotation.CheckForNull;
6+
import javax.annotation.Nonnull;
7+
58
import com.github.dockerjava.api.NotFoundException;
69

710
public interface CopyFileFromContainerCmd extends SyncDockerCmd<InputStream> {
811

12+
@CheckForNull
913
public String getContainerId();
1014

11-
public String getResource();
12-
13-
public CopyFileFromContainerCmd withContainerId(String containerId);
15+
@CheckForNull
16+
public String getHostPath();
1417

15-
public CopyFileFromContainerCmd withResource(String resource);
18+
@CheckForNull
19+
public String getResource();
1620

17-
public String getHostPath();
21+
public CopyFileFromContainerCmd withContainerId(@Nonnull String containerId);
1822

1923
public CopyFileFromContainerCmd withHostPath(String hostPath);
2024

25+
public CopyFileFromContainerCmd withResource(@Nonnull String resource);
26+
2127
/**
2228
* Its the responsibility of the caller to consume and/or close the {@link InputStream} to prevent connection leaks.
2329
*
@@ -29,5 +35,4 @@ public interface CopyFileFromContainerCmd extends SyncDockerCmd<InputStream> {
2935

3036
public static interface Exec extends DockerCmdSyncExec<CopyFileFromContainerCmd, InputStream> {
3137
}
32-
3338
}

0 commit comments

Comments
 (0)