This is an automated email from the ASF dual-hosted git repository.
He-Pin pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/pekko-projection.git
The following commit(s) were added to refs/heads/main by this push:
new 853b8d5b refactor: use Map.copyOf (Java 10+) (#546)
853b8d5b is described below
commit 853b8d5b70af1dd4a02f43a1161f694d90197599
Author: He-Pin(kerr) <[email protected]>
AuthorDate: Fri Jun 26 17:17:22 2026 +0800
refactor: use Map.copyOf (Java 10+) (#546)
Motivation:
Replace Collections.unmodifiableMap(new HashMap<>(...)) with the
more concise Map.copyOf() available since Java 10.
Modification:
Use Map.copyOf() which creates an immutable copy in a single call,
eliminating the intermediate mutable HashMap.
Result:
Cleaner, more concise code with fail-fast null rejection.
---
examples/src/test/java/jdocs/eventsourced/ShoppingCart.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/examples/src/test/java/jdocs/eventsourced/ShoppingCart.java
b/examples/src/test/java/jdocs/eventsourced/ShoppingCart.java
index dd3d61ca..33345a06 100644
--- a/examples/src/test/java/jdocs/eventsourced/ShoppingCart.java
+++ b/examples/src/test/java/jdocs/eventsourced/ShoppingCart.java
@@ -131,7 +131,7 @@ public class ShoppingCart
public record Summary(Map<String, Integer> items, boolean checkedOut)
implements CborSerializable {
public Summary {
- items = Collections.unmodifiableMap(new HashMap<>(items));
+ items = Map.copyOf(items);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]