aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/service
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2022-12-24 03:15:44 +0300
committerGravatar Vitaly Takmazov2022-12-24 03:15:44 +0300
commit2a858017b7d9a620d1083b69b7ca038c34a5ba89 (patch)
tree3b192b9ab0aee2a38bbd3243a2977409ae6a033e /src/main/java/com/juick/service
parent54f27794e7fee1113115baafe1b86fdbcde8e7c2 (diff)
`Collectors.toList()` -> `toList()`
Diffstat (limited to 'src/main/java/com/juick/service')
-rw-r--r--src/main/java/com/juick/service/MessagesServiceImpl.java4
-rw-r--r--src/main/java/com/juick/service/SubscriptionServiceImpl.java10
-rw-r--r--src/main/java/com/juick/service/TagServiceImpl.java9
-rw-r--r--src/main/java/com/juick/service/TelegramServiceImpl.java2
4 files changed, 12 insertions, 13 deletions
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();
}