summaryrefslogtreecommitdiffstats
path: root/component
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2022-11-30 10:04:50 +0100
committerHenning Baldersheim <balder@yahoo-inc.com>2022-11-30 10:04:50 +0100
commit448231f18ba53edf5c0e7ab4b6732ef69328281c (patch)
tree289f528fd6adac2a39e636c449c633c26fdb838e /component
parent711362f17d4bbece0dc2d0833a22063374ae3e04 (diff)
Reduce the simple usage of guava where java has caught up
Diffstat (limited to 'component')
-rw-r--r--component/src/main/java/com/yahoo/component/provider/ComponentRegistry.java15
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());
}
/**