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 9580099e refactor: migrate String.format to String.formatted (Java
15+) (#545)
9580099e is described below
commit 9580099e745f56a2915711c4594aa9b20e9a2412
Author: He-Pin(kerr) <[email protected]>
AuthorDate: Tue Jun 30 00:40:11 2026 +0800
refactor: migrate String.format to String.formatted (Java 15+) (#545)
* refactor: migrate String.format to String.formatted (Java 15+)
Motivation:
Java 15 introduced String.formatted() as an instance method counterpart
to String.format(), providing cleaner and more readable string formatting.
Modification:
Replace String.format("literal", args) with "literal".formatted(args)
in test example files.
Result:
More concise and idiomatic Java code leveraging Java 15+ API.
* style: fix javafmt formatting for String.formatted migration
Motivation:
The javafmt check failed in CI because the .formatted() call on a long
string was not wrapped to the next line.
Modification:
Apply javafmt formatting to ItemPopularityProjectionRepository.java.
Result:
Code style check passes in CI.
---
.../test/java/jdocs/guide/ItemPopularityProjectionRepository.java | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git
a/examples/src/test/java/jdocs/guide/ItemPopularityProjectionRepository.java
b/examples/src/test/java/jdocs/guide/ItemPopularityProjectionRepository.java
index 6375d980..ba0efc20 100644
--- a/examples/src/test/java/jdocs/guide/ItemPopularityProjectionRepository.java
+++ b/examples/src/test/java/jdocs/guide/ItemPopularityProjectionRepository.java
@@ -39,8 +39,7 @@ class ItemPopularityProjectionRepositoryImpl implements
ItemPopularityProjection
@Override
public CompletionStage<Done> update(String itemId, int delta) {
return session.executeWrite(
- String.format(
- "UPDATE %s.%s SET count = count + ? WHERE item_id = ?", Keyspace,
PopularityTable),
+ "UPDATE %s.%s SET count = count + ? WHERE item_id =
?".formatted(Keyspace, PopularityTable),
(long) delta,
itemId);
}
@@ -49,8 +48,8 @@ class ItemPopularityProjectionRepositoryImpl implements
ItemPopularityProjection
public CompletionStage<Optional<Long>> getItem(String itemId) {
return session
.selectOne(
- String.format(
- "SELECT item_id, count FROM %s.%s WHERE item_id = ?",
Keyspace, PopularityTable),
+ "SELECT item_id, count FROM %s.%s WHERE item_id = ?"
+ .formatted(Keyspace, PopularityTable),
itemId)
.thenApply(opt -> opt.map(row -> row.getLong("count")));
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]