Skip to content

Commit

Permalink
Improved usage of streams api
Browse files Browse the repository at this point in the history
  • Loading branch information
Hakky54 committed Feb 6, 2024
1 parent a47b85a commit c1c783f
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/main/java/nl/altindag/crip/command/PrintCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import picocli.CommandLine.Option;

import java.security.cert.X509Certificate;
import java.util.AbstractMap.SimpleImmutableEntry;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -58,13 +59,11 @@ public void run() {
case PEM:
urlsToCertificates.entrySet().stream()
.filter(entry -> !entry.getValue().isEmpty())
.collect(Collectors.toMap(
Map.Entry::getKey,
certificates -> CertificateUtils.convertToPem(certificates.getValue())))
.forEach((String path, List<String> certificate) ->
.map(entry -> new SimpleImmutableEntry<>(entry.getKey(), CertificateUtils.convertToPem(entry.getValue())))
.forEach(entry ->
System.out.printf("Certificates for url = %s%n%n%s%n%n",
path,
String.join(String.format(CERTIFICATE_DELIMITER, path), certificate)));
entry.getKey(),
String.join(String.format(CERTIFICATE_DELIMITER, entry.getKey()), entry.getValue())));
break;
}
}
Expand Down

0 comments on commit c1c783f

Please # to comment.