Blame view

src/main/java/fr/plil/sio/web/mvc/UserDaoImpl.java 1.06 KB
aa193b2b   Julien Iguchi-Cartigny   First version
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
  package fr.plil.sio.web.mvc;
  
  import java.util.HashSet;
  import java.util.Set;
  import org.springframework.stereotype.Repository;
  
  @Repository(value = "userDao")
  public class UserDaoImpl implements UserDao {
  
      private Set<User> users = new HashSet<User>();
  
      public UserDaoImpl() {
          User user = new User();
          user.setUsername("admin");
          user.setPassword("admin");
          users.add(user);
      }
  
      @Override
      public boolean save(User user) {        
          return users.add(user);
      }
  
      @Override
      public User getFromUsername(String username) {
          for (User user : users) {
              if (user.getUsername().equals(username)) {
                  return user;
              }
          }
          return null;
      }
  
      @Override
      public Set<User> getAllUsers() {
          return users;
      }
  
      @Override
      public boolean update(User user) {
          throw new UnsupportedOperationException("Not supported.");
      }
  
      @Override
      public boolean delete(User user) {
          throw new UnsupportedOperationException("Not supported.");
      }
  }