You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by re...@apache.org on 2024/11/29 09:44:18 UTC
(jackrabbit-oak) branch OAK-11288 updated: OAK-11288: remove usage of Immutable.Map.builder() - oak-store-composite
This is an automated email from the ASF dual-hosted git repository.
reschke pushed a commit to branch OAK-11288
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git
The following commit(s) were added to refs/heads/OAK-11288 by this push:
new 1376be6629 OAK-11288: remove usage of Immutable.Map.builder() - oak-store-composite
1376be6629 is described below
commit 1376be66295498aa75eb6198134f3431a424059a
Author: Julian Reschke <re...@apache.org>
AuthorDate: Fri Nov 29 10:44:08 2024 +0100
OAK-11288: remove usage of Immutable.Map.builder() - oak-store-composite
---
.../org/apache/jackrabbit/oak/composite/NodeMap.java | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/NodeMap.java b/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/NodeMap.java
index a78c3fca62..7060e10053 100644
--- a/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/NodeMap.java
+++ b/oak-store-composite/src/main/java/org/apache/jackrabbit/oak/composite/NodeMap.java
@@ -18,9 +18,10 @@
*/
package org.apache.jackrabbit.oak.composite;
-import org.apache.jackrabbit.guava.common.collect.ImmutableMap;
import org.apache.jackrabbit.oak.spi.mount.Mount;
+import java.util.Collections;
+import java.util.HashMap;
import java.util.Map;
import java.util.function.BiFunction;
import java.util.function.Function;
@@ -35,9 +36,9 @@ public class NodeMap<T> {
}
public static <T> NodeMap<T> create(Map<MountedNodeStore, T> nodes) {
- ImmutableMap.Builder<MountedNodeStore, CacheableSupplier<T>> suppliers = ImmutableMap.builder();
+ Map<MountedNodeStore, CacheableSupplier<T>> suppliers = new HashMap<>();
nodes.forEach((mns, node) -> suppliers.put(mns, new CacheableSupplier<T>(node)));
- return new NodeMap<>(suppliers.build());
+ return new NodeMap<>(Collections.unmodifiableMap(suppliers));
}
public T get(MountedNodeStore nodeStore) {
@@ -50,15 +51,15 @@ public class NodeMap<T> {
}
public <R> NodeMap<R> getAndApply(BiFunction<MountedNodeStore, T, R> function) {
- ImmutableMap.Builder<MountedNodeStore, CacheableSupplier<R>> newSuppliers = ImmutableMap.builder();
+ Map<MountedNodeStore, CacheableSupplier<R>> newSuppliers = new HashMap<>();
suppliers.forEach((mns, node) -> newSuppliers.put(mns, node.getAndApply(curry(function, mns))));
- return new NodeMap<>(newSuppliers.build());
+ return new NodeMap<>(Collections.unmodifiableMap(newSuppliers));
}
public <R> NodeMap<R> lazyApply(BiFunction<MountedNodeStore, T, R> function) {
- ImmutableMap.Builder<MountedNodeStore, CacheableSupplier<R>> newSuppliers = ImmutableMap.builder();
+ Map<MountedNodeStore, CacheableSupplier<R>> newSuppliers = new HashMap<>();
suppliers.forEach((mns, node) -> newSuppliers.put(mns, node.lazyApply(curry(function, mns))));
- return new NodeMap<>(newSuppliers.build());
+ return new NodeMap<>(Collections.unmodifiableMap(newSuppliers));
}
private static <T, U, R> Function<U, R> curry(BiFunction<T, U, R> function, T value) {
@@ -66,14 +67,14 @@ public class NodeMap<T> {
}
public NodeMap<T> replaceNode(MountedNodeStore nodeStore, T node) {
- ImmutableMap.Builder<MountedNodeStore, CacheableSupplier<T>> newSuppliers = ImmutableMap.builder();
+ Map<MountedNodeStore, CacheableSupplier<T>> newSuppliers = new HashMap<>();
suppliers.forEach((mns, n) -> {
if (mns != nodeStore) {
newSuppliers.put(mns, n);
}
});
newSuppliers.put(nodeStore, new CacheableSupplier<>(node));
- return new NodeMap<>(newSuppliers.build());
+ return new NodeMap<>(Collections.unmodifiableMap(newSuppliers));
}
private static class CacheableSupplier<T> implements Supplier<T> {