public User findUserByName(String username) { for (User user : users) { if (user.getUsername().equals(username)) { return user; } } return null; }
public void addUser(User user) { if (users.size() > 0) { for (int i = users.size() - 1; i >= 0; i--) { if (users.get(i).getUsername().equals(user.getUsername())) { users.remove(i); } } } users.add(user); }
private static User createUser( long id, String username, String firstName, String lastName, String email, String phone, int userStatus) { User user = new User(); user.setId(id); user.setUsername(username); user.setFirstName(firstName); user.setLastName(lastName); user.setEmail(email); user.setPassword("XXXXXXXXXXX"); user.setPhone(phone); user.setUserStatus(userStatus); return user; }