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

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