From 4391c0ee342fce1e6c1620dee128d9c5afa98a93 Mon Sep 17 00:00:00 2001 From: Richard Schmidt Date: Fri, 9 Feb 2024 21:57:16 +0100 Subject: [PATCH] refactoring: isUsernameAvailable in SignUpGUI --- src/main/java/SignUpGUI.java | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/main/java/SignUpGUI.java b/src/main/java/SignUpGUI.java index 70aa72f..faa360d 100644 --- a/src/main/java/SignUpGUI.java +++ b/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 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) {