diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2022-11-30 10:04:50 +0100 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2022-11-30 10:04:50 +0100 |
commit | 448231f18ba53edf5c0e7ab4b6732ef69328281c (patch) | |
tree | 289f528fd6adac2a39e636c449c633c26fdb838e /component/src | |
parent | 711362f17d4bbece0dc2d0833a22063374ae3e04 (diff) |
Reduce the simple usage of guava where java has caught up
Diffstat (limited to 'component/src')
-rw-r--r-- | component/src/main/java/com/yahoo/component/provider/ComponentRegistry.java | 15 |
1 files changed, 3 insertions, 12 deletions
diff --git a/component/src/main/java/com/yahoo/component/provider/ComponentRegistry.java b/component/src/main/java/com/yahoo/component/provider/ComponentRegistry.java index 1dddcbcc461..a64d6eb1090 100644 --- a/component/src/main/java/com/yahoo/component/provider/ComponentRegistry.java +++ b/component/src/main/java/com/yahoo/component/provider/ComponentRegistry.java @@ -1,7 +1,6 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.component.provider; -import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.yahoo.component.ComponentId; import com.yahoo.component.ComponentSpecification; @@ -56,17 +55,9 @@ public class ComponentRegistry<COMPONENT> { if (frozen) throw new IllegalStateException("Cannot modify a frozen component registry"); Map<String, Map<Version, COMPONENT>> componentVersionsByName = - componentsByNameByNamespace.get(id.getNamespace()); - if (componentVersionsByName == null) { - componentVersionsByName = new LinkedHashMap<>(); - componentsByNameByNamespace.put(id.getNamespace(), componentVersionsByName); - } + componentsByNameByNamespace.computeIfAbsent(id.getNamespace(), k -> new LinkedHashMap<>()); - Map<Version, COMPONENT> componentVersions = componentVersionsByName.get(id.getName()); - if (componentVersions == null) { - componentVersions = new LinkedHashMap<>(); - componentVersionsByName.put(id.getName(), componentVersions); - } + Map<Version, COMPONENT> componentVersions = componentVersionsByName.computeIfAbsent(id.getName(), k -> new LinkedHashMap<>()); componentVersions.put(id.getVersion(), component); componentsById.put(id, component); @@ -162,7 +153,7 @@ public class ComponentRegistry<COMPONENT> { * Returns an unmodifiable snapshot of all components present in this registry. */ public List<COMPONENT> allComponents() { - return ImmutableList.copyOf(componentsById.values()); + return List.copyOf(componentsById.values()); } /** |