UserService.java 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package es.uv.garcosda.services;
  2. import java.util.ArrayList;
  3. import java.util.Arrays;
  4. import java.util.List;
  5. import java.util.stream.Collectors;
  6. import org.springframework.stereotype.Service;
  7. import es.uv.garcosda.domain.User;
  8. @Service
  9. public class UserService {
  10. private List<User> users;
  11. public UserService() {
  12. users = new ArrayList<User>(
  13. Arrays.asList(new User("Quintina.Ardra@yopmail.com","Quintina","Ardra"),
  14. new User("Sybille.Land@yopmail.com","Sybille","Land"),
  15. new User("Kimmy.Elisha@yopmail.com","Kimmy","Elisha"),
  16. new User("Jeanna.McGrody@yopmail.com","Jeanna","McGrody"),
  17. new User("Lelah.Haymes@yopmail.com","Lelah","Haymes"),
  18. new User("Edith.Milson@yopmail.com","Edith","Milson"),
  19. new User("Minne.Eugenia@yopmail.com","Minne","Eugenia"),
  20. new User("Abbie.Brittani@yopmail.com","Abbie","Brittani"),
  21. new User("Brianna.Tacye@yopmail.com","Brianna","Tacye"),
  22. new User("Gabi.Clarissa@yopmail.com","Gabi","Clarissa"),
  23. new User("Aili.Evvie@yopmail.com","Aili","Evvie"),
  24. new User("Jillayne.Plato@yopmail.com","Jillayne","Plato"),
  25. new User("Allis.Daniele@yopmail.com","Allis","Daniele"),
  26. new User("Sam.Guildroy@yopmail.com","Sam","Guildroy"),
  27. new User("Sam.Argus@yopmail.com","Sam","Argus"),
  28. new User("Lorne.Kirbee@yopmail.com","Lorne","Kirbee"),
  29. new User("Brianna.Georgy@yopmail.com","Brianna","Georgy"),
  30. new User("Tarra.Gino@yopmail.com","Tarra","Gino"),
  31. new User("Elvira.Thornburg@yopmail.com","Elvira","Thornburg"),
  32. new User("Paola.Alice@yopmail.com","Paola","Alice")
  33. ));
  34. }
  35. public User findByEmail(String email) {
  36. List<User> ps = this.users.stream().filter(x -> x.getEmail().toLowerCase().equals(email.toLowerCase())).collect(Collectors.toList());
  37. if(ps.size() > 0) {
  38. return ps.get(0);
  39. }
  40. return new User();
  41. }
  42. }