diff options
author | sowgro <tpoke.ferrari@gmail.com> | 2025-03-30 14:34:10 -0400 |
---|---|---|
committer | sowgro <tpoke.ferrari@gmail.com> | 2025-03-30 14:34:10 -0400 |
commit | 9fba1c4af3c9b5aad206ec76469c1625125ea799 (patch) | |
tree | b31f52745944cfd6159b6fcef60b19fe4c80a3dc /ufund-api/src/main/java/com/ufund/api/ufundapi/persistence/CupboardFileDAO.java | |
parent | f23afc7f3b0b62384b3b54a0864b02abc3b48b01 (diff) | |
parent | 0c793d302c5065085ff7982a68f7ed449d84d6dc (diff) | |
download | JellySolutions-9fba1c4af3c9b5aad206ec76469c1625125ea799.tar.gz JellySolutions-9fba1c4af3c9b5aad206ec76469c1625125ea799.tar.bz2 JellySolutions-9fba1c4af3c9b5aad206ec76469c1625125ea799.zip |
Merge remote-tracking branch 'origin/main' into list-and-cupboard-component-refactor
# Conflicts:
# ufund-api/src/main/java/com/ufund/api/ufundapi/controller/CupboardController.java
# ufund-api/src/main/java/com/ufund/api/ufundapi/model/Need.java
# ufund-ui/src/app/components/cupboard/cupboard.component.ts
# ufund-ui/src/app/components/need-list/need-list.component.ts
# ufund-ui/src/app/models/Need.ts
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; } |