Example #1
0
 public User findByName(String name) {
   for (User user : users) {
     if (user.getName().equalsIgnoreCase(name)) {
       return user;
     }
   }
   return null;
 }
Example #2
0
 public User findById(long id) {
   for (User user : users) {
     if (user.getId() == id) {
       return user;
     }
   }
   return null;
 }
Example #3
0
  public void deleteUserById(long id) {

    for (Iterator<User> iterator = users.iterator(); iterator.hasNext(); ) {
      User user = iterator.next();
      if (user.getId() == id) {
        iterator.remove();
      }
    }
  }
Example #4
0
 public boolean isUserExist(User user) {
   return findByName(user.getName()) != null;
 }
Example #5
0
 public void saveUser(User user) {
   user.setId(counter.incrementAndGet());
   users.add(user);
 }