From 955124755c6c66b39dd006b471d82dc58300e8b6 Mon Sep 17 00:00:00 2001 From: amvanbaren Date: Mon, 9 Dec 2024 14:34:28 +0200 Subject: [PATCH] Replace SimpleEntry with Map.entry --- .../main/java/org/eclipse/openvsx/LocalRegistryService.java | 4 ++-- .../openvsx/admin/ChangeNamespaceJobRequestHandler.java | 4 ++-- .../java/org/eclipse/openvsx/mirror/DataMirrorService.java | 2 +- .../repositories/AdminStatisticCalculationsRepository.java | 4 ++-- .../openvsx/repositories/ExtensionVersionJooqRepository.java | 4 ++-- .../eclipse/openvsx/storage/AzureDownloadCountProcessor.java | 2 +- .../eclipse/openvsx/storage/AzureDownloadCountService.java | 4 ++-- .../java/org/eclipse/openvsx/storage/StorageUtilService.java | 4 ++-- 8 files changed, 14 insertions(+), 14 deletions(-) diff --git a/server/src/main/java/org/eclipse/openvsx/LocalRegistryService.java b/server/src/main/java/org/eclipse/openvsx/LocalRegistryService.java index ec1c2834e..806d97fae 100644 --- a/server/src/main/java/org/eclipse/openvsx/LocalRegistryService.java +++ b/server/src/main/java/org/eclipse/openvsx/LocalRegistryService.java @@ -194,7 +194,7 @@ private Map getDownloads(Extension extension, String targetPlatf logger.warn("Could not find download for: {}", NamingUtil.toLogFormat(ev)); return null; } else { - return new AbstractMap.SimpleEntry<>(ev.getTargetPlatform(), download); + return Map.entry(ev.getTargetPlatform(), download); } }) .filter(Objects::nonNull) @@ -788,7 +788,7 @@ private List toSearchEntries(SearchHits search var entry = e.getValue().toSearchEntryJson(); entry.setUrl(createApiUrl(serverUrl, "api", entry.getNamespace(), entry.getName())); entry.setVerified(isVerified(e.getValue(), membershipsByNamespaceId)); - return new AbstractMap.SimpleEntry<>(e.getKey(), entry); + return Map.entry(e.getKey(), entry); }) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); diff --git a/server/src/main/java/org/eclipse/openvsx/admin/ChangeNamespaceJobRequestHandler.java b/server/src/main/java/org/eclipse/openvsx/admin/ChangeNamespaceJobRequestHandler.java index 875c300ff..b601d73a9 100644 --- a/server/src/main/java/org/eclipse/openvsx/admin/ChangeNamespaceJobRequestHandler.java +++ b/server/src/main/java/org/eclipse/openvsx/admin/ChangeNamespaceJobRequestHandler.java @@ -136,7 +136,7 @@ private List> copyResources(Streamable(entry.getKey(), newExtension); + return Map.entry(entry.getKey(), newExtension); }) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); @@ -151,7 +151,7 @@ private List> copyResources(Streamable new AbstractMap.SimpleEntry<>(extVersion.getId(), newBinaryName(newNamespace, extVersion))) + .map(extVersion -> Map.entry(extVersion.getId(), newBinaryName(newNamespace, extVersion))) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); return resources.stream() diff --git a/server/src/main/java/org/eclipse/openvsx/mirror/DataMirrorService.java b/server/src/main/java/org/eclipse/openvsx/mirror/DataMirrorService.java index a47add37e..610777ebb 100644 --- a/server/src/main/java/org/eclipse/openvsx/mirror/DataMirrorService.java +++ b/server/src/main/java/org/eclipse/openvsx/mirror/DataMirrorService.java @@ -208,7 +208,7 @@ public void updateMetadata(String namespaceName, String extensionName, Extension var remoteReviews = upstream.getReviews(namespaceName, extensionName); var localReviews = repositories.findAllReviews(extension) - .map(review -> new AbstractMap.SimpleEntry<>(review.toReviewJson(), review)); + .map(review -> Map.entry(review.toReviewJson(), review)); remoteReviews.getReviews().stream() .filter(review -> localReviews.stream().noneMatch(entry -> entry.getKey().equals(review))) diff --git a/server/src/main/java/org/eclipse/openvsx/repositories/AdminStatisticCalculationsRepository.java b/server/src/main/java/org/eclipse/openvsx/repositories/AdminStatisticCalculationsRepository.java index f87aa1de8..af31ebc8c 100644 --- a/server/src/main/java/org/eclipse/openvsx/repositories/AdminStatisticCalculationsRepository.java +++ b/server/src/main/java/org/eclipse/openvsx/repositories/AdminStatisticCalculationsRepository.java @@ -81,7 +81,7 @@ public Map countActiveExtensionPublishersGroupedByExtensionsPu .groupBy(extensionCountsByPublisher.field(aliasExtensionCount, Integer.class)) .fetch() .stream() - .map(l -> new AbstractMap.SimpleEntry<>(l.value1(), l.value2())) + .map(l -> Map.entry(l.value1(), l.value2())) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); } @@ -108,7 +108,7 @@ public Map countActiveExtensionsGroupedByExtensionReviewRating( .groupBy(averageRatingByExtension.field(aliasAverageRating, Integer.class)) .fetch() .stream() - .map(l -> new AbstractMap.SimpleEntry<>(l.value1(), l.value2())) + .map(l -> Map.entry(l.value1(), l.value2())) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); } diff --git a/server/src/main/java/org/eclipse/openvsx/repositories/ExtensionVersionJooqRepository.java b/server/src/main/java/org/eclipse/openvsx/repositories/ExtensionVersionJooqRepository.java index 1f29e0209..cf2042b14 100644 --- a/server/src/main/java/org/eclipse/openvsx/repositories/ExtensionVersionJooqRepository.java +++ b/server/src/main/java/org/eclipse/openvsx/repositories/ExtensionVersionJooqRepository.java @@ -152,7 +152,7 @@ public Map> findActiveVersionStringsSorted(Collection e .map(row -> { var extensionId = row.get(top.field(EXTENSION_VERSION.EXTENSION_ID)); var version = row.get(top.field(EXTENSION_VERSION.VERSION)); - return new AbstractMap.SimpleEntry<>(extensionId, version); + return Map.entry(extensionId, version); }) .collect(Collectors.groupingBy(Map.Entry::getKey, Collectors.mapping(Map.Entry::getValue, Collectors.toList()))); } @@ -797,7 +797,7 @@ public Map findLatestIsPreview(Collection extensionIds) { return query.fetch(row -> { var id = row.get(EXTENSION.ID); var preview = row.get(latest.field(EXTENSION_VERSION.PREVIEW)); - return new AbstractMap.SimpleEntry<>(id, preview); + return Map.entry(id, preview); }) .stream() .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); diff --git a/server/src/main/java/org/eclipse/openvsx/storage/AzureDownloadCountProcessor.java b/server/src/main/java/org/eclipse/openvsx/storage/AzureDownloadCountProcessor.java index a03a14799..5060023d6 100644 --- a/server/src/main/java/org/eclipse/openvsx/storage/AzureDownloadCountProcessor.java +++ b/server/src/main/java/org/eclipse/openvsx/storage/AzureDownloadCountProcessor.java @@ -71,7 +71,7 @@ public void persistProcessedItem(String name, LocalDateTime processedOn, int exe public Map processDownloadCounts(Map files) { return Observation.createNotStarted("AzureDownloadCountProcessor#processDownloadCounts", observations).observe(() -> { return repositories.findDownloadsByStorageTypeAndName(STORAGE_AZURE, files.keySet()).stream() - .map(fileResource -> new AbstractMap.SimpleEntry<>(fileResource, files.get(fileResource.getName().toUpperCase()))) + .map(fileResource -> Map.entry(fileResource, files.get(fileResource.getName().toUpperCase()))) .collect(Collectors.groupingBy( e -> e.getKey().getExtension().getExtension().getId(), Collectors.summingInt(Map.Entry::getValue) diff --git a/server/src/main/java/org/eclipse/openvsx/storage/AzureDownloadCountService.java b/server/src/main/java/org/eclipse/openvsx/storage/AzureDownloadCountService.java index 64e30cf71..60568f2d9 100644 --- a/server/src/main/java/org/eclipse/openvsx/storage/AzureDownloadCountService.java +++ b/server/src/main/java/org/eclipse/openvsx/storage/AzureDownloadCountService.java @@ -204,13 +204,13 @@ && isExtensionPackageUri(node) }).map(node -> { var uri = node.get("uri").asText(); var pathParams = uri.substring(storageServiceEndpoint.length()).split("/"); - return new AbstractMap.SimpleEntry<>(pathParams, node.get("time").asText()); + return Map.entry(pathParams, node.get("time").asText()); }) .filter(entry -> storageBlobContainer.equals(entry.getKey()[1])) .map(entry -> { var pathParams = entry.getKey(); var fileName = UriUtils.decode(pathParams[pathParams.length - 1], StandardCharsets.UTF_8).toUpperCase(); - return new AbstractMap.SimpleEntry<>(fileName, 1); + return Map.entry(fileName, 1); }) .collect(Collectors.groupingBy(Map.Entry::getKey, Collectors.summingInt(Map.Entry::getValue))); } catch (IOException e) { diff --git a/server/src/main/java/org/eclipse/openvsx/storage/StorageUtilService.java b/server/src/main/java/org/eclipse/openvsx/storage/StorageUtilService.java index 8fea5cd82..eafa7ec18 100644 --- a/server/src/main/java/org/eclipse/openvsx/storage/StorageUtilService.java +++ b/server/src/main/java/org/eclipse/openvsx/storage/StorageUtilService.java @@ -254,8 +254,8 @@ public TempFile downloadFile(FileResource resource) throws IOException { */ public Map> getFileUrls(Collection extVersions, String serverUrl, String... types) { var type2Url = extVersions.stream() - .map(ev -> new AbstractMap.SimpleEntry>(ev.getId(), Maps.newLinkedHashMapWithExpectedSize(types.length))) - .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + .map(ev -> Map.>entry(ev.getId(), Maps.newLinkedHashMapWithExpectedSize(types.length))) + .collect(Collectors.>, Long, Map>toMap(Map.Entry::getKey, Map.Entry::getValue)); var resources = repositories.findFilesByType(extVersions, Arrays.asList(types)); for (var resource : resources) {