From ae9494bbca81e493f9a76da0029b113bf359e573 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Mon, 11 Jul 2016 10:22:01 +0300 Subject: cleanup sql, part 2 --- juick-core/src/main/java/com/juick/server/UserQueries.java | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 'juick-core/src/main') diff --git a/juick-core/src/main/java/com/juick/server/UserQueries.java b/juick-core/src/main/java/com/juick/server/UserQueries.java index eb2918c0..1ba0f83b 100644 --- a/juick-core/src/main/java/com/juick/server/UserQueries.java +++ b/juick-core/src/main/java/com/juick/server/UserQueries.java @@ -30,6 +30,7 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.*; +import java.util.stream.Collectors; /** * @@ -133,16 +134,7 @@ public class UserQueries { } public static boolean fillUsersByID(JdbcTemplate sql, List users) { - boolean ret = false; - - String uids = ""; - final int usersSize = users.size(); - for (int i = 0; i < usersSize; i++) { - if (i > 0) { - uids += ","; - } - uids += users.get(i).getUID(); - } + String uids = StringUtils.arrayToCommaDelimitedString(users.stream().map(u -> u.getUID()).collect(Collectors.toList()).toArray()); sql.query("SELECT id,nick,banned FROM users WHERE id IN (" + uids + ")", (rs, num) -> { -- cgit v1.2.3