aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/api/Users.java
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2016-01-10 18:54:05 +0300
committerGravatar Vitaly Takmazov2016-01-10 18:54:05 +0300
commitee86970fcae9878af0adcad00cf5333647b8babf (patch)
tree60c303f317236c2caab896173fafdaff1eebb115 /src/main/java/com/juick/api/Users.java
parent9eba4bda6dce22fb37d9156a5291f2cee3243361 (diff)
refactoring
Diffstat (limited to 'src/main/java/com/juick/api/Users.java')
-rw-r--r--src/main/java/com/juick/api/Users.java23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/main/java/com/juick/api/Users.java b/src/main/java/com/juick/api/Users.java
index 37c9ca49..5bae4028 100644
--- a/src/main/java/com/juick/api/Users.java
+++ b/src/main/java/com/juick/api/Users.java
@@ -1,16 +1,17 @@
package com.juick.api;
-import com.juick.User;
import com.juick.json.UserSerializer;
import com.juick.server.UserQueries;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.Connection;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
+import java.util.List;
/**
*
@@ -27,11 +28,11 @@ public class Users {
}
public void doGetUsers(HttpServletRequest request, HttpServletResponse response, int vuid) throws ServletException, IOException {
- ArrayList<com.juick.User> users = new ArrayList<User>();
+ List<com.juick.User> users = new ArrayList<>();
String punames[] = request.getParameterValues("uname");
if (punames != null) {
- ArrayList<String> unames = new ArrayList<String>(Arrays.asList(punames));
+ ArrayList<String> unames = new ArrayList<>(Arrays.asList(punames));
Iterator<String> i = unames.iterator();
while (i.hasNext()) {
if (!i.next().matches("^[a-zA-Z0-9\\-]{2,16}$")) {
@@ -45,7 +46,7 @@ public class Users {
String pjids[] = request.getParameterValues("jid");
if (pjids != null) {
- ArrayList<String> jids = new ArrayList<String>(Arrays.asList(pjids));
+ List<String> jids = new ArrayList<>(Arrays.asList(pjids));
Iterator<String> ii = jids.iterator();
while (ii.hasNext()) {
if (!ii.next().matches("^[a-zA-Z0-9\\-\\_\\@\\.]{6,64}$")) {
@@ -80,9 +81,9 @@ public class Users {
}
if (uid > 0) {
- ArrayList<Integer> uids = UserQueries.getUserRead(sql, uid);
+ List<Integer> uids = UserQueries.getUserRead(sql, uid);
if (uids.size() > 0) {
- ArrayList<com.juick.User> users = UserQueries.getUsersByID(sql, uids);
+ List<com.juick.User> users = UserQueries.getUsersByID(sql, uids);
if (users.size() > 0) {
String json = userSerializer.serializeList(users);
Main.replyJSON(request, response, json);
@@ -108,9 +109,9 @@ public class Users {
}
if (uid > 0) {
- ArrayList<Integer> uids = UserQueries.getUserReaders(sql, uid);
+ List<Integer> uids = UserQueries.getUserReaders(sql, uid);
if (uids.size() > 0) {
- ArrayList<com.juick.User> users = UserQueries.getUsersByID(sql, uids);
+ List<com.juick.User> users = UserQueries.getUsersByID(sql, uids);
if (users.size() > 0) {
String json = userSerializer.serializeList(users);
Main.replyJSON(request, response, json);