Skip to content

Commit 6ac2753

Browse files
committed
We are now on a modern version of guava, so remove code that is
a copy of guava clasess, and simplify. Signed-off-by: Nigel Magnay <nigel.magnay@gmail.com>
1 parent 63ea2fa commit 6ac2753

7 files changed

Lines changed: 9 additions & 640 deletions

File tree

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

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

3-
import static com.github.dockerjava.core.util.guava.Guava.join;
4-
53
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
64
import com.fasterxml.jackson.annotation.JsonProperty;
5+
import com.google.common.base.Joiner;
76

87
/**
98
*
@@ -32,12 +31,12 @@ public String toString() {
3231
StringBuffer buffer = new StringBuffer();
3332
buffer.append("[");
3433
for(String[] fields: processes) {
35-
buffer.append("[" + join(fields, "; ", true) + "]");
34+
buffer.append("[" + Joiner.on("; ").skipNulls().join(fields) + "]");
3635
}
3736
buffer.append("]");
3837

3938
return "TopContainerResponse{" +
40-
"titles=" + join(titles, "; ", true) +
39+
"titles=" + Joiner.on("; ").skipNulls().join(titles) +
4140
", processes=" + buffer.toString() +
4241
'}';
4342
}

src/main/java/com/github/dockerjava/core/dockerfile/Dockerfile.java

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -66,31 +66,7 @@ public Optional<? extends DockerfileStatement> apply(String input) {
6666
}
6767
}
6868

69-
/**
70-
* Not needed in modern guava
71-
*/
72-
private static class MissingOptionalFilter
73-
implements Predicate<Optional<? extends DockerfileStatement>> {
74-
75-
@Override
76-
public boolean apply(Optional<? extends DockerfileStatement> optional) {
77-
return (optional.orNull() != null);
78-
}
79-
}
80-
81-
/**
82-
* Not needed in modern guava
83-
*/
84-
private static class OptionalItemTransformer
85-
implements Function<Optional<? extends DockerfileStatement>, DockerfileStatement> {
86-
87-
@Override
88-
public DockerfileStatement apply(Optional<? extends DockerfileStatement> optional) {
89-
return optional.orNull();
90-
}
91-
}
92-
93-
public Collection<DockerfileStatement> getStatements() throws IOException {
69+
public Iterable<DockerfileStatement> getStatements() throws IOException {
9470
Collection<String> dockerFileContent = FileUtils.readLines(dockerFile);
9571

9672
if (dockerFileContent.size() <= 0) {
@@ -101,17 +77,7 @@ public Collection<DockerfileStatement> getStatements() throws IOException {
10177
Collection<Optional<? extends DockerfileStatement>> optionals = Collections2
10278
.transform(dockerFileContent, new LineTransformer());
10379

104-
// Modern guava would be done here,
105-
// With simply return Optional.presentInstances( optionals );
106-
//
107-
// So this entire function could simply be
108-
// return Optional.presentInstances( Collections2.transform( FileUtils.readLines(dockerFile), new LineTransformer() ) );
109-
//
110-
// Until the dawn of that day, do it manually
111-
112-
return Collections2.transform(Collections2.filter(optionals, new MissingOptionalFilter()),
113-
new OptionalItemTransformer());
114-
80+
return Optional.presentInstances(optionals);
11581
}
11682

11783
public List<String> getIgnores() throws IOException {

src/main/java/com/github/dockerjava/core/dockerfile/DockerfileStatement.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,15 +188,13 @@ public static Optional<? extends DockerfileStatement> createFromLine(String cmd)
188188

189189
line = Add.create(cmd);
190190

191-
// if (line.isPresent()) { : Newer guava
192-
if (line.orNull() != null) {
191+
if (line.isPresent()) {
193192
return line;
194193
}
195194

196195
line = Env.create(cmd);
197196

198-
// if (line.isPresent()) { : Newer guava
199-
if (line.orNull() != null) {
197+
if (line.isPresent()) {
200198
return line;
201199
}
202200

src/main/java/com/github/dockerjava/core/util/guava/Guava.java

Lines changed: 0 additions & 45 deletions
This file was deleted.

src/main/java/com/github/dockerjava/core/util/guava/PercentEscaper.java

Lines changed: 0 additions & 245 deletions
This file was deleted.

0 commit comments

Comments
 (0)