diff --git a/src/main/java/io/fabric8/maven/docker/model/ContainerDetails.java b/src/main/java/io/fabric8/maven/docker/model/ContainerDetails.java index 9b556b267..ba77f76f7 100644 --- a/src/main/java/io/fabric8/maven/docker/model/ContainerDetails.java +++ b/src/main/java/io/fabric8/maven/docker/model/ContainerDetails.java @@ -1,5 +1,9 @@ package io.fabric8.maven.docker.model; +import com.google.common.base.Joiner; +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; + import java.time.Instant; import java.util.Collections; import java.util.HashMap; @@ -7,11 +11,6 @@ import java.util.Map; import java.util.Set; -import com.google.common.base.Joiner; -import com.google.common.base.Preconditions; -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; - public class ContainerDetails implements Container { @@ -77,10 +76,8 @@ public Map getLabels() { public String getName() { String name = json.get(NAME).getAsString(); - if (name.startsWith(SLASH)) { - name = name.substring(1); - } - return name; + return name.startsWith(SLASH) ? name.substring(1) : + name; } @Override diff --git a/src/main/java/io/fabric8/maven/docker/model/ContainersListElement.java b/src/main/java/io/fabric8/maven/docker/model/ContainersListElement.java index 3381b7d28..9be25e1e7 100644 --- a/src/main/java/io/fabric8/maven/docker/model/ContainersListElement.java +++ b/src/main/java/io/fabric8/maven/docker/model/ContainersListElement.java @@ -1,13 +1,12 @@ package io.fabric8.maven.docker.model; +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; + import java.util.Collections; import java.util.HashMap; -import java.util.Iterator; import java.util.Map; -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; - public class ContainersListElement implements Container { static final String CREATED = "Created"; @@ -133,9 +132,7 @@ private Map mapLabels(JsonObject labels) { int length = labels.size(); Map mapped = new HashMap<>(length); - Iterator iterator = labels.keySet().iterator(); - while (iterator.hasNext()) { - String key = iterator.next(); + for (String key : labels.keySet()) { mapped.put(key, labels.get(key).getAsString()); }