Skip to content

Commit

Permalink
Changed while loop to enhanced for loop in ContainersListElement.java…
Browse files Browse the repository at this point in the history
… and Removed the if statement and replace with ternary statement in ContainerDetails.java

Signed-off-by: M. <[email protected]>
Co-Authored-By: Rohan Kumar <[email protected]>
  • Loading branch information
mdxabu and rohanKanojia committed Feb 22, 2024
1 parent e8c5826 commit 2faa068
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
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;
import java.util.Iterator;
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 {

Expand Down Expand Up @@ -77,10 +76,8 @@ public Map<String, String> 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
Expand Down
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -133,9 +132,7 @@ private Map<String, String> mapLabels(JsonObject labels) {
int length = labels.size();
Map<String, String> mapped = new HashMap<>(length);

Iterator<String> iterator = labels.keySet().iterator();
while (iterator.hasNext()) {
String key = iterator.next();
for (String key : labels.keySet()) {
mapped.put(key, labels.get(key).getAsString());
}

Expand Down

0 comments on commit 2faa068

Please sign in to comment.