You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@pekko.apache.org by "He-Pin (via GitHub)" <gi...@apache.org> on 2026/06/25 20:32:48 UTC
[PR] refactor: migrate Collections/Arrays.asList to Java 9+ collection factories [pekko-projection]
He-Pin opened a new pull request, #543:
URL: https://github.com/apache/pekko-projection/pull/543
### Motivation
Java 9+ provides `List.of()`, `Map.of()`, `Set.of()` factory methods that are more concise and return truly immutable collections.
### Modification
- Replace `Arrays.asList(...)` with `List.of()`
- Replace `Collections.singletonList()` with `List.of()`
- Replace `Collections.unmodifiableList(Arrays.asList(...))` with `List.of()`
- Replace `Collections.singleton()` with `Set.of()`
- Update imports accordingly
### Result
Cleaner code using Java 17 immutable collection factories. 10 files changed.
### Tests
Not run - compile-only test file changes
### References
None - Java 17 API modernization
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] refactor: migrate Collections/Arrays.asList to Java 9+ collection factories [pekko-projection]
Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
pjfanning commented on code in PR #543:
URL: https://github.com/apache/pekko-projection/pull/543#discussion_r3477509515
##########
examples/src/test/java/jdocs/guide/EventGeneratorApp.java:
##########
@@ -197,7 +197,7 @@ static class CartPersistentBehavior
public CartPersistentBehavior(PersistenceId persistenceId, String tag) {
super(persistenceId);
this.tag = tag;
- this.tags = new HashSet<>(Collections.singletonList(tag));
+ this.tags = new HashSet<>(List.of(tag));
Review Comment:
Set.of?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] refactor: migrate Collections/Arrays.asList to Java 9+ collection factories [pekko-projection]
Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
He-Pin commented on code in PR #543:
URL: https://github.com/apache/pekko-projection/pull/543#discussion_r3480428161
##########
examples/src/test/java/jdocs/guide/EventGeneratorApp.java:
##########
@@ -197,7 +197,7 @@ static class CartPersistentBehavior
public CartPersistentBehavior(PersistenceId persistenceId, String tag) {
super(persistenceId);
this.tag = tag;
- this.tags = new HashSet<>(Collections.singletonList(tag));
+ this.tags = new HashSet<>(List.of(tag));
Review Comment:
Yes, Set.of(tag) is correct here — the `tags` field is typed as `Set<String>` and was previously assigned via `new HashSet<>(Collections.singletonList(tag))`. `Set.of(tag)` produces an immutable single-element Set directly, eliminating the intermediate singletonList + HashSet wrapping.
Note: the PRODUCTS field (List<String>) retains `List.of(...)` since its declared type is List and usage relies on positional access via `PRODUCTS.size()`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] refactor: migrate Collections/Arrays.asList to Java 9+ collection factories [pekko-projection]
Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
He-Pin merged PR #543:
URL: https://github.com/apache/pekko-projection/pull/543
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org