diff options
author | Vitaly Takmazov | 2022-12-24 03:15:44 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2022-12-24 03:15:44 +0300 |
commit | 2a858017b7d9a620d1083b69b7ca038c34a5ba89 (patch) | |
tree | 3b192b9ab0aee2a38bbd3243a2977409ae6a033e /src/main/java/com/juick | |
parent | 54f27794e7fee1113115baafe1b86fdbcde8e7c2 (diff) |
`Collectors.toList()` -> `toList()`
Diffstat (limited to 'src/main/java/com/juick')
12 files changed, 31 insertions, 32 deletions
diff --git a/src/main/java/com/juick/ServerManager.java b/src/main/java/com/juick/ServerManager.java index 50389705..a33d7d9a 100644 --- a/src/main/java/com/juick/ServerManager.java +++ b/src/main/java/com/juick/ServerManager.java @@ -168,6 +168,6 @@ public class ServerManager implements NotificationListener { Message ping = new Message(); ping.setService(true); sendSseEvent(ping, "ping", getSessions().stream().map(s -> s.user) - .distinct().collect(Collectors.toList())); + .distinct().toList()); } } diff --git a/src/main/java/com/juick/TopManager.java b/src/main/java/com/juick/TopManager.java index faa225d8..d7917fbc 100644 --- a/src/main/java/com/juick/TopManager.java +++ b/src/main/java/com/juick/TopManager.java @@ -48,7 +48,7 @@ public class TopManager { public void updateTop() { messagesService.getPopularCandidates().forEach(m -> { Message jmsg = messagesService.getMessage(m).orElseThrow(IllegalStateException::new); - List<String> tags = jmsg.getTags().stream().map(Tag::getName).map(String::toLowerCase).collect(Collectors.toList()); + List<String> tags = jmsg.getTags().stream().map(Tag::getName).map(String::toLowerCase).toList(); if (!tags.contains("juick")) { CommandResult result = commandsManager.commandRecommend(serviceUser, URI.create(StringUtils.EMPTY), String.valueOf(m)); logger.info("Popular message {}: {}", m, result.getText()); 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<Pair<Integer, User>> 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<User> subscribers = userService.getUserReaders(uid); List<User> 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<User> users = ListUtils.union(subscribers, mentionedUsers); List<Integer> tags = tagService.getMessageTagsIDs(mid); List<String> 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<User> mentionedUsers = userService.getUsersByName(MessageUtils.getMentions(reply).stream() - .map(u -> u.substring(1)).collect(Collectors.toList())); + .map(u -> u.substring(1)).toList()); List<User> 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<Tag> getTags(Stream<String> 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<Integer> 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<Tag> addedTags = newTags.stream().filter(t -> !currentTags.contains(t)).collect(Collectors.toList()); + List<Tag> 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<Tag> tags = tagsStream.get().map(t -> getTag(t.substring(1), true)) - .distinct().collect(Collectors.toSet()); + Set<Tag> 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<Long> getTelegramIdentifiers(List<User> users) { - List<Integer> uids = users.stream().map(User::getUid).collect(Collectors.toList()); + List<Integer> uids = users.stream().map(User::getUid).toList(); if (uids.isEmpty()) { return Collections.emptyList(); } diff --git a/src/main/java/com/juick/www/api/Notifications.java b/src/main/java/com/juick/www/api/Notifications.java index 5f941ba5..09dad9e2 100644 --- a/src/main/java/com/juick/www/api/Notifications.java +++ b/src/main/java/com/juick/www/api/Notifications.java @@ -76,11 +76,11 @@ public class Notifications { pushQueriesService.getMPNSURL(uid).forEach(t -> user.getTokens().add(new ExternalToken(null, "mpns", t, null))); List<ExternalToken> xmppJids = userService.getJIDsbyUID(uid).stream() .map(jid -> new ExternalToken(null, "xmpp", jid, null)) - .collect(Collectors.toList()); + .toList(); user.getTokens().addAll(xmppJids); List<ExternalToken> tgIds = telegramService.getTelegramIdentifiers(Collections.singletonList(user)).stream() .map(tgId -> new ExternalToken(null, "durov", String.valueOf(tgId), null)) - .collect(Collectors.toList()); + .toList(); user.getTokens().addAll(tgIds); return user; } @@ -116,7 +116,7 @@ public class Notifications { } return users.stream().map(User::getUid) - .map(this::collectTokens).collect(Collectors.toList()); + .map(this::collectTokens).toList(); } else { // read return Collections.singletonList(collectTokens(uid)); diff --git a/src/main/java/com/juick/www/api/activity/Profile.java b/src/main/java/com/juick/www/api/activity/Profile.java index c87d6118..fb66400d 100644 --- a/src/main/java/com/juick/www/api/activity/Profile.java +++ b/src/main/java/com/juick/www/api/activity/Profile.java @@ -142,7 +142,7 @@ public class Profile { String personUri = uri.path(String.format("/u/%s", userName)).toUriString(); List<Integer> mids = messagesService.getUserBlog(user.getUid(), 0, before); List<Note> notes = messagesService.getMessages(visitor, mids).stream().map(activityPubManager::makeNote) - .collect(Collectors.toList()); + .toList(); OrderedCollectionPage page = new OrderedCollectionPage(); page.setPartOf(uri.replacePath(String.format("/u/%s/blog/toc", userName)).toUriString()); page.setFirst(uri.replacePath(String.format("/u/%s/blog", userName)).toUriString()); @@ -155,7 +155,7 @@ public class Profile { create.setObject(a); create.setPublished(a.getPublished()); return create; - }).collect(Collectors.toList())); + }).toList()); int beforeNext = mids.stream().reduce((fst, second) -> second).orElse(0); if (beforeNext > 0) { page.setNext(uri.queryParam("before", beforeNext).toUriString()); @@ -200,7 +200,7 @@ public class Profile { follower.setPreferredUsername(a.getName()); follower.setUrl(profileUriBuilder.personWebUri(a)); return follower; - }).collect(Collectors.toList())); + }).toList()); boolean hasNext = followers.size() <= 20 * page; if (hasNext) { result.setNext(uriComponentsBuilder.queryParam("page", page + 1).toUriString()); @@ -244,7 +244,7 @@ public class Profile { follower.setPreferredUsername(a.getName()); follower.setUrl(profileUriBuilder.personWebUri(a)); return follower; - }).collect(Collectors.toList())); + }).toList()); boolean hasNext = following.size() <= 20 * page; if (hasNext) { result.setNext(uriComponentsBuilder.queryParam("page", page + 1).toUriString()); diff --git a/src/main/java/com/juick/www/controllers/Settings.java b/src/main/java/com/juick/www/controllers/Settings.java index 0b486766..b990bf41 100644 --- a/src/main/java/com/juick/www/controllers/Settings.java +++ b/src/main/java/com/juick/www/controllers/Settings.java @@ -107,7 +107,7 @@ public class Settings { model.addAttribute("emails", userService.getEmails(visitor)); model.addAttribute("jids", userService.getAllJIDs(visitor)); List<String> hours = IntStream.rangeClosed(0, 23).boxed() - .map(i -> StringUtils.leftPad(String.format("%d", i), 2, "0")).collect(Collectors.toList()); + .map(i -> StringUtils.leftPad(String.format("%d", i), 2, "0")).toList(); model.addAttribute("hours", hours); model.addAttribute("fbstatus", userService.getFbCrossPostStatus(visitor.getUid())); model.addAttribute("twitter_name", userService.getTwitterName(visitor.getUid())); diff --git a/src/main/java/com/juick/www/controllers/Site.java b/src/main/java/com/juick/www/controllers/Site.java index dcb89718..dadf7ed6 100644 --- a/src/main/java/com/juick/www/controllers/Site.java +++ b/src/main/java/com/juick/www/controllers/Site.java @@ -95,7 +95,7 @@ public class Site { model.addAttribute("tagStats", tagService.getUserTagStats(user.getUid()).stream() .sorted((e1, e2) -> Integer.compare(e2.getUsageCount(), e1.getUsageCount())).limit(20) - .map(t -> t.getTag().getName()).collect(Collectors.toList())); + .map(t -> t.getTag().getName()).toList()); } @GetMapping("/login") @@ -195,7 +195,7 @@ public class Site { List<Integer> unread = messagesService.getUnread(visitor); visitor.setUnreadCount(unread.size()); List<Integer> blUIDs = userService.checkBL(visitor.getUid(), - msgs.stream().map(m -> m.getUser().getUid()).collect(Collectors.toList())); + msgs.stream().map(m -> m.getUser().getUid()).toList()); msgs.forEach(m -> m.ReadOnly |= blUIDs.contains(m.getUser().getUid())); } model.addAttribute("msgs", msgs); @@ -301,7 +301,7 @@ public class Site { List<Integer> unread = messagesService.getUnread(visitor); visitor.setUnreadCount(unread.size()); List<Integer> blUIDs = userService.checkBL(visitor.getUid(), - msgs.stream().map(m -> m.getUser().getUid()).collect(Collectors.toList())); + msgs.stream().map(m -> m.getUser().getUid()).toList()); msgs.forEach(m -> m.ReadOnly |= blUIDs.contains(m.getUser().getUid())); } model.addAttribute("msgs", msgs); @@ -338,7 +338,7 @@ public class Site { model.addAttribute("tags", tagService.getUserTagStats(user.getUid()).stream() .sorted((e1, e2) -> Integer.compare(e2.getUsageCount(), e1.getUsageCount())) - .map(t -> t.getTag().getName()).collect(Collectors.toList())); + .map(t -> t.getTag().getName()).toList()); return "views/blog_tags"; } @@ -423,7 +423,7 @@ public class Site { List<Integer> unread = messagesService.getUnread(visitor); visitor.setUnreadCount(unread.size()); List<Integer> blUIDs = userService.checkBL(visitor.getUid(), - msgs.stream().map(m -> m.getUser().getUid()).collect(Collectors.toList())); + msgs.stream().map(m -> m.getUser().getUid()).toList()); msgs.forEach(m -> m.ReadOnly |= blUIDs.contains(m.getUser().getUid())); fillUserModel(model, visitor, visitor); } @@ -569,7 +569,7 @@ public class Site { model.addAttribute("visitorSubscribed", messagesService.isSubscribed(visitor.getUid(), msg.getMid())); model.addAttribute("visitorInBL", userService.isInBL(msg.getUser().getUid(), visitor.getUid())); model.addAttribute("recomm", messagesService.getMessagesRecommendations(Collections.singletonList(msg.getMid())) - .stream().map(Pair::getRight).collect(Collectors.toList())); + .stream().map(Pair::getRight).toList()); List<Integer> blUIDs = new ArrayList<>(); for (Message reply : replies) { if (reply.getUser().getUid() != msg.getUser().getUid() && !blUIDs.contains(reply.getUser().getUid())) { @@ -609,7 +609,7 @@ public class Site { model.addAttribute("tags", tagService.getUserTagStats(visitor.getUid()).stream() .sorted((e1, e2) -> Integer.compare(e2.getUsageCount(), e1.getUsageCount())) - .map(t -> t.getTag().getName()).collect(Collectors.toList())); + .map(t -> t.getTag().getName()).toList()); return "views/post"; } diff --git a/src/main/java/com/juick/www/rss/MessagesView.java b/src/main/java/com/juick/www/rss/MessagesView.java index dde67d7b..71d63754 100644 --- a/src/main/java/com/juick/www/rss/MessagesView.java +++ b/src/main/java/com/juick/www/rss/MessagesView.java @@ -84,7 +84,7 @@ public class MessagesView extends AbstractRssFeedView { protected List<Item> buildFeedItems(Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) { List<Message> msgs = (List<Message>) model.get("messages"); - return msgs.stream().map(this::createRssItem).collect(Collectors.toList()); + return msgs.stream().map(this::createRssItem).toList(); } @Override diff --git a/src/main/java/com/juick/www/rss/RepliesView.java b/src/main/java/com/juick/www/rss/RepliesView.java index 83c8e104..80548a79 100644 --- a/src/main/java/com/juick/www/rss/RepliesView.java +++ b/src/main/java/com/juick/www/rss/RepliesView.java @@ -65,7 +65,7 @@ public class RepliesView extends AbstractRssFeedView { HttpServletRequest request, HttpServletResponse response) { List<ResponseReply> msgs = (List<ResponseReply>)model.get("messages"); - return msgs.stream().map(this::createRssItem).collect(Collectors.toList()); + return msgs.stream().map(this::createRssItem).toList(); } @Override |