aboutsummaryrefslogtreecommitdiff
path: root/ufund-api/src/main/java/com/ufund/api/ufundapi/service/CupboardService.java
diff options
context:
space:
mode:
authorsowgro <tpoke.ferrari@gmail.com>2025-03-06 22:53:36 -0500
committersowgro <tpoke.ferrari@gmail.com>2025-03-06 22:53:36 -0500
commita3fbcd713ae9a6b3f38dcc42a5c4c2f369a5d6f5 (patch)
treeed019f6dc374df3da88b1cdadaeaae92e799b96e /ufund-api/src/main/java/com/ufund/api/ufundapi/service/CupboardService.java
parent7cb123c21bef247a2216545bc18245136f2ddf78 (diff)
downloadJellySolutions-a3fbcd713ae9a6b3f38dcc42a5c4c2f369a5d6f5.tar.gz
JellySolutions-a3fbcd713ae9a6b3f38dcc42a5c4c2f369a5d6f5.tar.bz2
JellySolutions-a3fbcd713ae9a6b3f38dcc42a5c4c2f369a5d6f5.zip
more javadocs and cleanup
Diffstat (limited to 'ufund-api/src/main/java/com/ufund/api/ufundapi/service/CupboardService.java')
-rw-r--r--ufund-api/src/main/java/com/ufund/api/ufundapi/service/CupboardService.java27
1 files changed, 19 insertions, 8 deletions
diff --git a/ufund-api/src/main/java/com/ufund/api/ufundapi/service/CupboardService.java b/ufund-api/src/main/java/com/ufund/api/ufundapi/service/CupboardService.java
index 6052e4f..15f8442 100644
--- a/ufund-api/src/main/java/com/ufund/api/ufundapi/service/CupboardService.java
+++ b/ufund-api/src/main/java/com/ufund/api/ufundapi/service/CupboardService.java
@@ -6,22 +6,27 @@ import java.util.Arrays;
import com.ufund.api.ufundapi.model.Need;
import com.ufund.api.ufundapi.persistence.CupboardDAO;
import org.springframework.stereotype.Component;
+import com.ufund.api.ufundapi.DuplicateKeyException;
@Component
public class CupboardService {
private final CupboardDAO cupboardDAO;
- public class DuplicateKeyException extends Exception {
- public DuplicateKeyException(String message) {
- super(message);
- }
- }
-
public CupboardService(CupboardDAO cupboardDAO) {
this.cupboardDAO = cupboardDAO;
}
+ /**
+ * Creates a new Need
+ *
+ * @param name The name of the need to create
+ * @param maxGoal The max goal of the new need
+ * @param goalType The goal type of the new need
+ * @return The need that was created
+ * @throws IOException Thrown if there was any issue saving the data
+ * @throws DuplicateKeyException If there already exists a need with the same name
+ */
public Need createNeed(String name, int maxGoal, Need.GoalType goalType) throws IOException, DuplicateKeyException {
Need need = new Need(name, goalType, maxGoal);
@@ -39,6 +44,12 @@ public class CupboardService {
}
+ /**
+ * Get all the needs in the cupboard
+ *
+ * @return An array containing all needs
+ * @throws IOException Thrown if there was any issue saving the data
+ */
public Need[] getNeeds() throws IOException {
return cupboardDAO.getNeeds();
}
@@ -48,7 +59,7 @@ public class CupboardService {
*
* @param search The search substring
* @return The requested array
- * @throws IOException
+ * @throws IOException Thrown if there was any issue saving the data
*/
public Need[] searchNeeds(String search) throws IOException {
return Arrays.stream(cupboardDAO.getNeeds())
@@ -68,7 +79,7 @@ public class CupboardService {
/**
* Modify a need
- *
+ * // TODO
* @param need
* @return
* @throws IOException Thrown if there was an issue saving the changes