예제 #1
0
 public User findByName(String name) {
   for (User user : users) {
     if (user.getName().equalsIgnoreCase(name)) {
       return user;
     }
   }
   return null;
 }
예제 #2
0
 public User findById(long id) {
   for (User user : users) {
     if (user.getId() == id) {
       return user;
     }
   }
   return null;
 }
예제 #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();
      }
    }
  }
예제 #4
0
 public boolean isUserExist(User user) {
   return findByName(user.getName()) != null;
 }
예제 #5
0
 public void saveUser(User user) {
   user.setId(counter.incrementAndGet());
   users.add(user);
 }