Browse Source

refactoring: isUsernameAvailable in SignUpGUI

main
Richard Schmidt 11 months ago
parent
commit
4391c0ee34
  1. 9
      src/main/java/SignUpGUI.java

9
src/main/java/SignUpGUI.java

@ -149,14 +149,7 @@ public class SignUpGUI extends JFrame implements ActionListener {
// Function to check if the input username doesn't already exist in the JSON file
private boolean isUsernameAvailable(String filename, String username) {
List<CreateUser> userList = CreateUser.readUserListFromJsonFile(filename);
if (userList != null) {
for (CreateUser user : userList) {
if (user.getUserName().equals(username)) {
return false;
}
}
}
return true;
return userList == null || userList.stream().noneMatch(user -> user.getUserName().equals(username));
}
public static void main(String[] args) {

Loading…
Cancel
Save