From 2a858017b7d9a620d1083b69b7ca038c34a5ba89 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Sat, 24 Dec 2022 03:15:44 +0300 Subject: `Collectors.toList()` -> `toList()` --- src/main/java/com/juick/service/MessagesServiceImpl.java | 4 ++-- src/main/java/com/juick/service/SubscriptionServiceImpl.java | 10 +++++----- src/main/java/com/juick/service/TagServiceImpl.java | 9 ++++----- src/main/java/com/juick/service/TelegramServiceImpl.java | 2 +- 4 files changed, 12 insertions(+), 13 deletions(-) (limited to 'src/main/java/com/juick/service') diff --git a/src/main/java/com/juick/service/MessagesServiceImpl.java b/src/main/java/com/juick/service/MessagesServiceImpl.java index 366d14f5..3a4c3767 100644 --- a/src/main/java/com/juick/service/MessagesServiceImpl.java +++ b/src/main/java/com/juick/service/MessagesServiceImpl.java @@ -431,7 +431,7 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ List> allRecommendations = getMessagesRecommendations(List.of(mid)); message.setRecommendations(new HashSet<>(allRecommendations.stream() - .filter(r -> r.getLeft().equals(mid)).map(Pair::getRight).collect(Collectors.toList()))); + .filter(r -> r.getLeft().equals(mid)).map(Pair::getRight).toList())); message.getRecommendations().forEach(r -> r.setAvatar(webApp.getAvatarUrl(r))); return Optional.of(message); } @@ -855,7 +855,7 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ msgs.forEach(m -> { m.setRecommendations(new HashSet<>(allRecommendations.stream() - .filter(r -> r.getLeft().equals(m.getMid())).map(Pair::getRight).collect(Collectors.toList()))); + .filter(r -> r.getLeft().equals(m.getMid())).map(Pair::getRight).toList())); m.getRecommendations().forEach(r -> r.setAvatar(webApp.getAvatarUrl(r))); }); diff --git a/src/main/java/com/juick/service/SubscriptionServiceImpl.java b/src/main/java/com/juick/service/SubscriptionServiceImpl.java index 0b8d9f26..2e475256 100644 --- a/src/main/java/com/juick/service/SubscriptionServiceImpl.java +++ b/src/main/java/com/juick/service/SubscriptionServiceImpl.java @@ -60,9 +60,9 @@ public class SubscriptionServiceImpl extends BaseJdbcService implements Subscrip List subscribers = userService.getUserReaders(uid); List mentionedUsers = userService.getUsersByName(MessageUtils.getMentions(msg).stream() .map(u -> u.substring(1)) - .collect(Collectors.toList())).stream() + .toList()).stream() .filter(u -> !userService.isInBL(u.getUid(), msg.getUser().getUid())) - .collect(Collectors.toList()); + .toList(); List users = ListUtils.union(subscribers, mentionedUsers); List tags = tagService.getMessageTagsIDs(mid); List tagsStr = tagService.getMessageTags(mid).stream().map(t -> t.getTag().getName()) @@ -105,12 +105,12 @@ public class SubscriptionServiceImpl extends BaseJdbcService implements Subscrip Integer.class, msg.getMid(), reply.getUser().getUid())); List mentionedUsers = userService.getUsersByName(MessageUtils.getMentions(reply).stream() - .map(u -> u.substring(1)).collect(Collectors.toList())); + .map(u -> u.substring(1)).toList()); List users = IteratorUtils.toList(CollectionUtils.union(subscribers, mentionedUsers).iterator()); if (!users.isEmpty()) { return users.stream() .filter(u -> blacklisted || !u.isBanned() && !userService.isReplyToBL(u, reply)) - .collect(Collectors.toList()); + .toList(); } return Collections.emptyList(); } @@ -125,7 +125,7 @@ public class SubscriptionServiceImpl extends BaseJdbcService implements Subscrip .filter(u -> !userService.isInBLAny(u.getUid(), msg.getUser().getUid())) .filter(u -> Collections.disjoint(tagService.getUserBLTags(u.getUid()), msgTags)) - .collect(Collectors.toList()); + .toList(); } return Collections.emptyList(); } diff --git a/src/main/java/com/juick/service/TagServiceImpl.java b/src/main/java/com/juick/service/TagServiceImpl.java index 07dffc23..e7852bc2 100644 --- a/src/main/java/com/juick/service/TagServiceImpl.java +++ b/src/main/java/com/juick/service/TagServiceImpl.java @@ -100,7 +100,7 @@ public class TagServiceImpl extends BaseJdbcService implements TagService { public List getTags(Stream tags, final boolean autoCreate) { return tags.filter(StringUtils::isNotBlank).map(tag -> getTag(tag, autoCreate)).filter(Objects::nonNull) .distinct() - .collect(Collectors.toList()); + .toList(); } @Transactional(readOnly = true) @@ -201,7 +201,7 @@ public class TagServiceImpl extends BaseJdbcService implements TagService { List idsForDelete = newTags.stream() .filter(currentTags::contains) .map(tag -> tag.TID) - .collect(Collectors.toList()); + .toList(); if (newTags.size() - idsForDelete.size() >= 5) { return currentTags; } @@ -211,7 +211,7 @@ public class TagServiceImpl extends BaseJdbcService implements TagService { "DELETE FROM messages_tags WHERE message_id = :mid AND tag_id in (:ids)", new MapSqlParameterSource().addValue("ids", idsForDelete).addValue("mid", mid)); - List addedTags = newTags.stream().filter(t -> !currentTags.contains(t)).collect(Collectors.toList()); + List addedTags = newTags.stream().filter(t -> !currentTags.contains(t)).toList(); getJdbcTemplate().batchUpdate("INSERT INTO messages_tags(message_id,tag_id) VALUES (?,?)", new BatchPreparedStatementSetter() { @Override @@ -237,8 +237,7 @@ public class TagServiceImpl extends BaseJdbcService implements TagService { .takeWhile(t -> t.matches("\\*[^\\s]+|#[^\\s]*[^\\d][^\\s]*")); int tagsLength = tagsStream.get().collect(Collectors.joining(" ")).length(); String body = txt.substring(tagsLength); - Set tags = tagsStream.get().map(t -> getTag(t.substring(1), true)) - .distinct().collect(Collectors.toSet()); + Set tags = tagsStream.get().map(t -> getTag(t.substring(1), true)).collect(Collectors.toSet()); return Pair.of(body, tags); } diff --git a/src/main/java/com/juick/service/TelegramServiceImpl.java b/src/main/java/com/juick/service/TelegramServiceImpl.java index 9239a330..12142e7a 100644 --- a/src/main/java/com/juick/service/TelegramServiceImpl.java +++ b/src/main/java/com/juick/service/TelegramServiceImpl.java @@ -72,7 +72,7 @@ public class TelegramServiceImpl extends BaseJdbcService implements TelegramServ @Transactional(readOnly = true) @Override public List getTelegramIdentifiers(List users) { - List uids = users.stream().map(User::getUid).collect(Collectors.toList()); + List uids = users.stream().map(User::getUid).toList(); if (uids.isEmpty()) { return Collections.emptyList(); } -- cgit v1.2.3