diff options
author | sowgro <tpoke.ferrari@gmail.com> | 2025-03-27 18:55:39 -0400 |
---|---|---|
committer | sowgro <tpoke.ferrari@gmail.com> | 2025-03-27 18:55:39 -0400 |
commit | d6f4aad157baad7d9b25d56ce056b80805e88f5f (patch) | |
tree | 1b4a3df94389afb1637ea59fe47ba3a327c89561 /ufund-api/src/main/java/com/ufund/api/ufundapi/persistence/CupboardFileDAO.java | |
parent | 96f833352eff7b9428daf2add988ecd0a2b41d92 (diff) | |
parent | ddbd1cc688aa98fb275ad72a750fbaaf53e6c0ae (diff) | |
download | JellySolutions-d6f4aad157baad7d9b25d56ce056b80805e88f5f.tar.gz JellySolutions-d6f4aad157baad7d9b25d56ce056b80805e88f5f.tar.bz2 JellySolutions-d6f4aad157baad7d9b25d56ce056b80805e88f5f.zip |
Merge branch 'main' into css
Diffstat (limited to 'ufund-api/src/main/java/com/ufund/api/ufundapi/persistence/CupboardFileDAO.java')
-rw-r--r-- | ufund-api/src/main/java/com/ufund/api/ufundapi/persistence/CupboardFileDAO.java | 31 |
1 files changed, 11 insertions, 20 deletions
diff --git a/ufund-api/src/main/java/com/ufund/api/ufundapi/persistence/CupboardFileDAO.java b/ufund-api/src/main/java/com/ufund/api/ufundapi/persistence/CupboardFileDAO.java index 521acae..7efda83 100644 --- a/ufund-api/src/main/java/com/ufund/api/ufundapi/persistence/CupboardFileDAO.java +++ b/ufund-api/src/main/java/com/ufund/api/ufundapi/persistence/CupboardFileDAO.java @@ -1,15 +1,16 @@ package com.ufund.api.ufundapi.persistence; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.ufund.api.ufundapi.model.Need; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Component; - import java.io.File; import java.io.IOException; import java.util.Map; import java.util.TreeMap; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.ufund.api.ufundapi.model.Need; + @Component public class CupboardFileDAO implements CupboardDAO { @@ -52,31 +53,20 @@ public class CupboardFileDAO implements CupboardDAO { } /** - * Return an array of the needs - * - * @return An array of all the needs - */ - private Need[] getNeedsArray() { - return needs.values().toArray(Need[]::new); - } - - /** * Saves the needs to json * - * @return True if the save was successful, false otherwise * @throws IOException If there was an IO issue saving the file */ - private boolean save() throws IOException { - Need[] needArray = getNeedsArray(); + private void save() throws IOException { + Need[] needArray = needs.values().toArray(Need[]::new); objectMapper.writeValue(new File(filename), needArray); - return true; } @Override public Need[] getNeeds() { synchronized (needs) { - return getNeedsArray(); + return needs.values().toArray(Need[]::new); } } @@ -117,7 +107,8 @@ public class CupboardFileDAO implements CupboardDAO { synchronized (needs) { if (needs.containsKey(id)) { needs.remove(id); - return save(); + save(); + return true; } else { return false; } |