Skip to content

Instantly share code, notes, and snippets.

@Adrianvdh
Last active December 24, 2017 06:45
Show Gist options
  • Save Adrianvdh/1e6c73a05587fa536f105c2f702ae3d4 to your computer and use it in GitHub Desktop.
Save Adrianvdh/1e6c73a05587fa536f105c2f702ae3d4 to your computer and use it in GitHub Desktop.
class UserService {
List<User> users = new ArrayList<>();
{
User user = new User();
user.username = "adrianvdh";
user.password = "hello123";
users.add(user);
}
public User authenticate(String username, String password) {
User foundUser = null;
for (User userInCollection : users) {
if (userInCollection.username.equals(username)) {
foundUser = userInCollection;
break;
}
}
return foundUser;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment