From f75c59fefa8c39bab8fb0b91979d811bc98359f6 Mon Sep 17 00:00:00 2001
From: Tan Yi Xian <>
Date: Sun, 6 Nov 2022 14:45:10 +0800
Subject: [PATCH 01/25] Add javadoc headers for classes related to testing
---
.../foodrem/commons/core/index/IndexTest.java | 3 ++
.../seedu/foodrem/logic/LogicManagerTest.java | 8 ++-
.../generalcommands/ExitCommandTest.java | 3 ++
.../generalcommands/HelpCommandTest.java | 3 ++
.../generalcommands/ResetCommandTest.java | 3 ++
.../itemcommands/DecrementCommandTest.java | 3 ++
.../itemcommands/EditCommandTest.java | 5 +-
.../itemcommands/EditItemDescriptorTest.java | 3 ++
.../itemcommands/FilterTagCommandTest.java | 3 ++
.../itemcommands/IncrementCommandTest.java | 3 ++
.../commands/itemcommands/NewCommandTest.java | 13 ++---
.../itemcommands/SortCommandTest.java | 3 ++
.../itemcommands/ViewCommandTest.java | 3 ++
.../tagcommands/DeleteTagCommandTest.java | 3 ++
.../tagcommands/NewTagCommandTest.java | 3 ++
.../tagcommands/RenameTagCommandTest.java | 3 ++
.../commands/tagcommands/TagCommandTest.java | 3 ++
.../tagcommands/UntagCommandTest.java | 3 ++
.../logic/parser/FoodRemParserTest.java | 3 ++
.../foodrem/logic/parser/ParserUtilTest.java | 53 ++-----------------
.../HelpCommandParserTest.java | 3 ++
.../DecrementCommandParserTest.java | 3 ++
.../EditCommandParserTest.java | 6 ++-
.../FilterTagCommandParserTest.java | 3 ++
.../IncrementCommandParserTest.java | 3 ++
.../NewCommandParserTest.java | 3 ++
.../RemarkCommandParserTest.java | 3 ++
.../SortCommandParserTest.java | 3 ++
.../ViewCommandParserTest.java | 3 ++
.../DeleteTagCommandParserTest.java | 3 ++
.../NewTagCommandParserTest.java | 3 ++
.../RenameTagCommandParserTest.java | 3 ++
.../TagCommandParserTest.java | 3 ++
.../UntagCommandParserTest.java | 3 ++
.../seedu/foodrem/model/ModelManagerTest.java | 3 ++
.../model/item/UniqueItemListTest.java | 3 ++
.../ItemBoughtDateValidatorTest.java | 3 ++
.../ItemExpiryDateValidatorTest.java | 3 ++
.../itemvalidators/ItemNameValidatorTest.java | 3 ++
.../ItemQuantityValidatorTest.java | 3 ++
.../itemvalidators/ItemUnitValidatorTest.java | 3 ++
.../itemvalidators/ItemValidatorUtilTest.java | 3 ++
.../foodrem/storage/JsonAdaptedItemTest.java | 18 ++++---
.../storage/JsonFoodRemStorageTest.java | 3 ++
.../storage/JsonSerializableFoodRemTest.java | 5 +-
.../storage/JsonUserPrefsStorageTest.java | 3 ++
.../foodrem/storage/StorageManagerTest.java | 3 ++
.../testutil/EditItemDescriptorBuilder.java | 9 ++++
.../java/seedu/foodrem/testutil/ItemUtil.java | 10 ----
.../java/seedu/foodrem/ui/UiPartTest.java | 3 ++
50 files changed, 163 insertions(+), 87 deletions(-)
diff --git a/src/test/java/seedu/foodrem/commons/core/index/IndexTest.java b/src/test/java/seedu/foodrem/commons/core/index/IndexTest.java
index a1240544a06..fe4aeab65a1 100644
--- a/src/test/java/seedu/foodrem/commons/core/index/IndexTest.java
+++ b/src/test/java/seedu/foodrem/commons/core/index/IndexTest.java
@@ -7,6 +7,9 @@
import org.junit.jupiter.api.Test;
+/**
+ * A class to test the Index.
+ */
public class IndexTest {
@Test
public void createOneBasedIndex() {
diff --git a/src/test/java/seedu/foodrem/logic/LogicManagerTest.java b/src/test/java/seedu/foodrem/logic/LogicManagerTest.java
index e4fc32e89a5..688122f0d47 100644
--- a/src/test/java/seedu/foodrem/logic/LogicManagerTest.java
+++ b/src/test/java/seedu/foodrem/logic/LogicManagerTest.java
@@ -27,6 +27,9 @@
import seedu.foodrem.testutil.ItemBuilder;
import seedu.foodrem.testutil.TypicalItems;
+/**
+ * A class to test LogicManager.
+ */
public class LogicManagerTest {
private static final IOException DUMMY_IO_EXCEPTION = new IOException("dummy exception");
private static final String EXPECTED_SUCCESS_MESSAGE = "Listed all items";
@@ -89,11 +92,6 @@ public void execute_storageThrowsIoException_throwsCommandException() {
assertCommandFailure(addCommand, CommandException.class, expectedMessage, expectedModel);
}
- //@Test
- //public void getFilteredItemList_modifyList_throwsUnsupportedOperationException() {
- // assertThrows(UnsupportedOperationException.class, () -> logic.getFilteredItemList().remove(0));
- //}
-
/**
* Executes the command and confirms that
* - no exceptions are thrown
diff --git a/src/test/java/seedu/foodrem/logic/commands/generalcommands/ExitCommandTest.java b/src/test/java/seedu/foodrem/logic/commands/generalcommands/ExitCommandTest.java
index 4fe7d6c6733..70d1ea3f514 100644
--- a/src/test/java/seedu/foodrem/logic/commands/generalcommands/ExitCommandTest.java
+++ b/src/test/java/seedu/foodrem/logic/commands/generalcommands/ExitCommandTest.java
@@ -12,6 +12,9 @@
import seedu.foodrem.model.UserPrefs;
import seedu.foodrem.testutil.TypicalFoodRem;
+/**
+ * A class to test the ExitCommand.
+ */
class ExitCommandTest {
private final Model model = new ModelManager(TypicalFoodRem.getTypicalFoodRem(), new UserPrefs());
diff --git a/src/test/java/seedu/foodrem/logic/commands/generalcommands/HelpCommandTest.java b/src/test/java/seedu/foodrem/logic/commands/generalcommands/HelpCommandTest.java
index cc8654c9a53..08f19b03329 100644
--- a/src/test/java/seedu/foodrem/logic/commands/generalcommands/HelpCommandTest.java
+++ b/src/test/java/seedu/foodrem/logic/commands/generalcommands/HelpCommandTest.java
@@ -13,6 +13,9 @@
import seedu.foodrem.model.UserPrefs;
import seedu.foodrem.testutil.TypicalFoodRem;
+/**
+ * A class to test the HelpCommand.
+ */
class HelpCommandTest {
private final Model model = new ModelManager(TypicalFoodRem.getTypicalFoodRem(), new UserPrefs());
diff --git a/src/test/java/seedu/foodrem/logic/commands/generalcommands/ResetCommandTest.java b/src/test/java/seedu/foodrem/logic/commands/generalcommands/ResetCommandTest.java
index 8d438a9eec8..3ce1e25a8c4 100644
--- a/src/test/java/seedu/foodrem/logic/commands/generalcommands/ResetCommandTest.java
+++ b/src/test/java/seedu/foodrem/logic/commands/generalcommands/ResetCommandTest.java
@@ -10,6 +10,9 @@
import seedu.foodrem.model.UserPrefs;
import seedu.foodrem.testutil.TypicalFoodRem;
+/**
+ * A class to test the ResetCommand.
+ */
class ResetCommandTest {
private static final String EXPECTED_SUCCESS_MESSAGE = "FoodRem has been reset!";
private final Model model = new ModelManager(TypicalFoodRem.getTypicalFoodRem(), new UserPrefs());
diff --git a/src/test/java/seedu/foodrem/logic/commands/itemcommands/DecrementCommandTest.java b/src/test/java/seedu/foodrem/logic/commands/itemcommands/DecrementCommandTest.java
index 7da7e188857..ee8e0d49e71 100644
--- a/src/test/java/seedu/foodrem/logic/commands/itemcommands/DecrementCommandTest.java
+++ b/src/test/java/seedu/foodrem/logic/commands/itemcommands/DecrementCommandTest.java
@@ -21,6 +21,9 @@
import seedu.foodrem.testutil.MessageToUser;
import seedu.foodrem.viewmodels.ItemWithMessage;
+/**
+ * A class to test the DecrementCommand.
+ */
class DecrementCommandTest {
private static final String EXPECTED_SUCCESS_MESSAGE = "Decremented successfully and updated item as follows:";
diff --git a/src/test/java/seedu/foodrem/logic/commands/itemcommands/EditCommandTest.java b/src/test/java/seedu/foodrem/logic/commands/itemcommands/EditCommandTest.java
index 557b0a8c910..2971710b44e 100644
--- a/src/test/java/seedu/foodrem/logic/commands/itemcommands/EditCommandTest.java
+++ b/src/test/java/seedu/foodrem/logic/commands/itemcommands/EditCommandTest.java
@@ -32,6 +32,7 @@
*/
public class EditCommandTest {
private static final String EXPECTED_SUCCESS_MESSAGE = "Item successfully edited with the following values:";
+ private static final String MESSAGE_DUPLICATE_ITEM = "This item already exists in FoodRem.";
private final Model model = new ModelManager(TypicalFoodRem.getTypicalFoodRem(), new UserPrefs());
@@ -111,7 +112,7 @@ public void execute_duplicateItemUnfilteredList_failure() {
EditItemDescriptor descriptor = new EditItemDescriptorBuilder(firstItem).build();
EditCommand editCommand = new EditCommand(INDEX_SECOND_ITEM, descriptor);
- assertCommandFailure(editCommand, model, EditCommand.MESSAGE_DUPLICATE_ITEM);
+ assertCommandFailure(editCommand, model, MESSAGE_DUPLICATE_ITEM);
}
@Test
@@ -122,7 +123,7 @@ public void execute_duplicateItemFilteredList_failure() {
Item itemInList = model.getFoodRem().getItemList().get(INDEX_SECOND_ITEM.getZeroBased());
EditCommand editCommand = new EditCommand(INDEX_FIRST_ITEM, new EditItemDescriptorBuilder(itemInList).build());
- assertCommandFailure(editCommand, model, EditCommand.MESSAGE_DUPLICATE_ITEM);
+ assertCommandFailure(editCommand, model, MESSAGE_DUPLICATE_ITEM);
}
@Test
diff --git a/src/test/java/seedu/foodrem/logic/commands/itemcommands/EditItemDescriptorTest.java b/src/test/java/seedu/foodrem/logic/commands/itemcommands/EditItemDescriptorTest.java
index 60875c1dd84..d0d50056a68 100644
--- a/src/test/java/seedu/foodrem/logic/commands/itemcommands/EditItemDescriptorTest.java
+++ b/src/test/java/seedu/foodrem/logic/commands/itemcommands/EditItemDescriptorTest.java
@@ -10,6 +10,9 @@
import seedu.foodrem.logic.commands.itemcommands.EditCommand.EditItemDescriptor;
import seedu.foodrem.testutil.EditItemDescriptorBuilder;
+/**
+ * A class to test the EditItemDescriptor.
+ */
public class EditItemDescriptorTest {
@Test
public void equals() {
diff --git a/src/test/java/seedu/foodrem/logic/commands/itemcommands/FilterTagCommandTest.java b/src/test/java/seedu/foodrem/logic/commands/itemcommands/FilterTagCommandTest.java
index ba8fea19f50..204ea25ff48 100644
--- a/src/test/java/seedu/foodrem/logic/commands/itemcommands/FilterTagCommandTest.java
+++ b/src/test/java/seedu/foodrem/logic/commands/itemcommands/FilterTagCommandTest.java
@@ -18,6 +18,9 @@
import seedu.foodrem.testutil.TagBuilder;
import seedu.foodrem.viewmodels.FilterByTag;
+/**
+ * A class to test the FilterTagCommand.
+ */
public class FilterTagCommandTest {
private static final String EXPECTED_ERROR_NOT_FOUND = "This tag does not exist in FoodRem";
private static final String EXPECTED_SUCCESS_LIST_AFTER_FILTERING = "%1$d items filtered";
diff --git a/src/test/java/seedu/foodrem/logic/commands/itemcommands/IncrementCommandTest.java b/src/test/java/seedu/foodrem/logic/commands/itemcommands/IncrementCommandTest.java
index 522fca5ac93..5706cda10c0 100644
--- a/src/test/java/seedu/foodrem/logic/commands/itemcommands/IncrementCommandTest.java
+++ b/src/test/java/seedu/foodrem/logic/commands/itemcommands/IncrementCommandTest.java
@@ -21,6 +21,9 @@
import seedu.foodrem.testutil.MessageToUser;
import seedu.foodrem.viewmodels.ItemWithMessage;
+/**
+ * A class to test the IncrementCommand.
+ */
class IncrementCommandTest {
private static final String EXPECTED_SUCCESS_MESSAGE = "Incremented successfully and updated item as follows:";
diff --git a/src/test/java/seedu/foodrem/logic/commands/itemcommands/NewCommandTest.java b/src/test/java/seedu/foodrem/logic/commands/itemcommands/NewCommandTest.java
index 29237bc0978..9b2c5ee36f5 100644
--- a/src/test/java/seedu/foodrem/logic/commands/itemcommands/NewCommandTest.java
+++ b/src/test/java/seedu/foodrem/logic/commands/itemcommands/NewCommandTest.java
@@ -26,6 +26,9 @@
import seedu.foodrem.testutil.ItemBuilder;
import seedu.foodrem.viewmodels.ItemWithMessage;
+/**
+ * A class to test the NewCommand.
+ */
public class NewCommandTest {
private static final String EXPECTED_SUCCESS_MESSAGE = "New item added as follows:";
private static final String EXPECTED_FAILURE_DUPLICATE_ITEM = "This item already exists in FoodRem";
@@ -108,16 +111,6 @@ public void updateSortedItemList(Comparator- comparator) {
throw new AssertionError("This method should not be called.");
}
- @Override
- public boolean isItemStorageFull() {
- throw new AssertionError("This method should not be called.");
- }
-
- @Override
- public boolean isTagStorageFull() {
- throw new AssertionError("This method should not be called.");
- }
-
@Override
public void updateFilteredTagList(Predicate predicate) {
throw new AssertionError("This method should not be called.");
diff --git a/src/test/java/seedu/foodrem/logic/commands/itemcommands/SortCommandTest.java b/src/test/java/seedu/foodrem/logic/commands/itemcommands/SortCommandTest.java
index ff623af3ad8..8f93f60d7e8 100644
--- a/src/test/java/seedu/foodrem/logic/commands/itemcommands/SortCommandTest.java
+++ b/src/test/java/seedu/foodrem/logic/commands/itemcommands/SortCommandTest.java
@@ -21,6 +21,9 @@
import seedu.foodrem.model.item.itemcomparators.ItemRemarkComparator;
import seedu.foodrem.model.item.itemcomparators.ItemUnitComparator;
+/**
+ * A class to test the SortCommand.
+ */
class SortCommandTest {
private final Model model = new ModelManager(getSortFoodRem(), new UserPrefs());
diff --git a/src/test/java/seedu/foodrem/logic/commands/itemcommands/ViewCommandTest.java b/src/test/java/seedu/foodrem/logic/commands/itemcommands/ViewCommandTest.java
index 5d89cc77110..538bca0c5e0 100644
--- a/src/test/java/seedu/foodrem/logic/commands/itemcommands/ViewCommandTest.java
+++ b/src/test/java/seedu/foodrem/logic/commands/itemcommands/ViewCommandTest.java
@@ -17,6 +17,9 @@
import seedu.foodrem.model.UserPrefs;
import seedu.foodrem.model.item.Item;
+/**
+ * A class to test the ViewCommand.
+ */
class ViewCommandTest {
private final Model model = new ModelManager(getTypicalFoodRem(), new UserPrefs());
diff --git a/src/test/java/seedu/foodrem/logic/commands/tagcommands/DeleteTagCommandTest.java b/src/test/java/seedu/foodrem/logic/commands/tagcommands/DeleteTagCommandTest.java
index 560ccc9cffe..f42746e5483 100644
--- a/src/test/java/seedu/foodrem/logic/commands/tagcommands/DeleteTagCommandTest.java
+++ b/src/test/java/seedu/foodrem/logic/commands/tagcommands/DeleteTagCommandTest.java
@@ -22,6 +22,9 @@
import seedu.foodrem.testutil.TypicalTags;
import seedu.foodrem.viewmodels.TagsWithMessage;
+/**
+ * A class to test the DeleteTagCommand.
+ */
public class DeleteTagCommandTest {
private static final String EXPECTED_ERROR_NOT_FOUND = "This tag does not exist in FoodRem";
private static final String EXPECTED_SUCCESS_MESSAGE = "Tag deleted:";
diff --git a/src/test/java/seedu/foodrem/logic/commands/tagcommands/NewTagCommandTest.java b/src/test/java/seedu/foodrem/logic/commands/tagcommands/NewTagCommandTest.java
index 5c928505452..403caa0008f 100644
--- a/src/test/java/seedu/foodrem/logic/commands/tagcommands/NewTagCommandTest.java
+++ b/src/test/java/seedu/foodrem/logic/commands/tagcommands/NewTagCommandTest.java
@@ -19,6 +19,9 @@
import seedu.foodrem.testutil.TagBuilder;
import seedu.foodrem.viewmodels.TagsWithMessage;
+/**
+ * A class to test the NewTagCommand.
+ */
public class NewTagCommandTest {
private static final String EXPECTED_ERROR_DUPLICATE = "This tag already exists in FoodRem";
private static final String EXPECTED_SUCCESS_MESSAGE = "New tag added:";
diff --git a/src/test/java/seedu/foodrem/logic/commands/tagcommands/RenameTagCommandTest.java b/src/test/java/seedu/foodrem/logic/commands/tagcommands/RenameTagCommandTest.java
index 7ed272473e2..1ccd1ea428d 100644
--- a/src/test/java/seedu/foodrem/logic/commands/tagcommands/RenameTagCommandTest.java
+++ b/src/test/java/seedu/foodrem/logic/commands/tagcommands/RenameTagCommandTest.java
@@ -19,6 +19,9 @@
import seedu.foodrem.testutil.TagBuilder;
import seedu.foodrem.viewmodels.TagToRename;
+/**
+ * A class to test the RenameTagCommand.
+ */
public class RenameTagCommandTest {
private static final String EXPECTED_ERROR_NOT_FOUND = "This tag does not exist in FoodRem.";
private static final String EXPECTED_ERROR_DUPLICATE = "This tag name already exists in FoodRem.";
diff --git a/src/test/java/seedu/foodrem/logic/commands/tagcommands/TagCommandTest.java b/src/test/java/seedu/foodrem/logic/commands/tagcommands/TagCommandTest.java
index b215af51089..557cd3ffed4 100644
--- a/src/test/java/seedu/foodrem/logic/commands/tagcommands/TagCommandTest.java
+++ b/src/test/java/seedu/foodrem/logic/commands/tagcommands/TagCommandTest.java
@@ -27,6 +27,9 @@
import seedu.foodrem.testutil.TypicalTags;
import seedu.foodrem.viewmodels.ItemWithMessage;
+/**
+ * A class to test the TagCommand.
+ */
public class TagCommandTest {
private static final String EXPECTED_SUCCESS_MESSAGE = "Item tagged successfully. Updated item:";
private static final String ERROR_DUPLICATE = "This item has already been tagged with this tag";
diff --git a/src/test/java/seedu/foodrem/logic/commands/tagcommands/UntagCommandTest.java b/src/test/java/seedu/foodrem/logic/commands/tagcommands/UntagCommandTest.java
index 2f0e00362f3..1fa3faef85b 100644
--- a/src/test/java/seedu/foodrem/logic/commands/tagcommands/UntagCommandTest.java
+++ b/src/test/java/seedu/foodrem/logic/commands/tagcommands/UntagCommandTest.java
@@ -27,6 +27,9 @@
import seedu.foodrem.testutil.TypicalTags;
import seedu.foodrem.viewmodels.ItemWithMessage;
+/**
+ * A class to test the UntagCommand.
+ */
public class UntagCommandTest {
private static final String EXPECTED_SUCCESS_MESSAGE = "Item untagged successfully. Updated item:";
private static final String ERROR_ITEM_DOES_NOT_CONTAIN_TAG = "This item has not been tagged with this tag";
diff --git a/src/test/java/seedu/foodrem/logic/parser/FoodRemParserTest.java b/src/test/java/seedu/foodrem/logic/parser/FoodRemParserTest.java
index af317c49e2a..5b4114715b1 100644
--- a/src/test/java/seedu/foodrem/logic/parser/FoodRemParserTest.java
+++ b/src/test/java/seedu/foodrem/logic/parser/FoodRemParserTest.java
@@ -44,6 +44,9 @@
import seedu.foodrem.testutil.TagUtil;
import seedu.foodrem.testutil.TypicalIndexes;
+/**
+ * A class to test the FoodRemParser.
+ */
public class FoodRemParserTest {
private final FoodRemParser parser = new FoodRemParser();
diff --git a/src/test/java/seedu/foodrem/logic/parser/ParserUtilTest.java b/src/test/java/seedu/foodrem/logic/parser/ParserUtilTest.java
index a9f2eb19a63..fd6b2fd40c7 100644
--- a/src/test/java/seedu/foodrem/logic/parser/ParserUtilTest.java
+++ b/src/test/java/seedu/foodrem/logic/parser/ParserUtilTest.java
@@ -12,18 +12,19 @@
import seedu.foodrem.model.item.ItemQuantity;
import seedu.foodrem.model.item.ItemUnit;
+/**
+ * A class to test the ParserUtil.
+ */
public class ParserUtilTest {
private static final String VALID_ITEM_NAME = "Potatoes";
private static final String VALID_ITEM_QUANTITY = "10";
private static final String VALID_ITEM_UNIT = "kg";
private static final String VALID_ITEM_BOUGHT_DATE = "11-11-2022";
- private static final String VALID_ITEM_EXPIRY_DATE = "11-11-2022";
private static final String INVALID_ITEM_NAME = "Potatoes|/";
private static final String INVALID_ITEM_QUANTITY = "10|/";
private static final String INVALID_ITEM_UNIT = "kg|/";
private static final String INVALID_ITEM_BOUGHT_DATE = "11-11-2022|/";
- private static final String INVALID_ITEM_EXPIRY_DATE = "11-11-2022|/";
private static final String WHITESPACE = " \t\r\n";
@@ -161,52 +162,4 @@ public void parseExpiryDate_validValueWithWhitespace_returnsTrimmedExpiryDate()
ItemExpiryDate expectedExpiryDate = ItemExpiryDate.of(VALID_ITEM_BOUGHT_DATE);
assertEquals(expectedExpiryDate, ParserUtil.parseExpiryDate(expireDateWithWhitespace));
}
-
- // TODO: Implement test for tags one functionality is added
- //@Test
- //public void parseTag_null_throwsNullPointerException() {
- // assertThrows(NullPointerException.class, () -> ParserUtil.parseTag(null));
- //}
- //
- //@Test
- //public void parseTag_invalidValue_throwsIllegalArgumentException() {
- // assertThrows(IllegalArgumentException.class, () -> ParserUtil.parseTag(INVALID_TAG));
- //}
- //
- //@Test
- //public void parseTag_validValueWithoutWhitespace_returnsTag() {
- // Tag expectedTag = new Tag(VALID_TAG_1);
- // assertEquals(expectedTag, ParserUtil.parseTag(VALID_TAG_1));
- //}
- //
- //@Test
- //public void parseTag_validValueWithWhitespace_returnsTrimmedTag() {
- // String tagWithWhitespace = WHITESPACE + VALID_TAG_1 + WHITESPACE;
- // Tag expectedTag = new Tag(VALID_TAG_1);
- // assertEquals(expectedTag, ParserUtil.parseTag(tagWithWhitespace));
- //}
-
- //@Test
- //public void parseTags_null_throwsNullPointerException() {
- // assertThrows(NullPointerException.class, () -> ParserUtil.parseTags(null));
- //}
- //
- //@Test
- //public void parseTags_collectionWithInvalidTags_throwsIllegalArgumentException() {
- // assertThrows(IllegalArgumentException.class,
- // () -> ParserUtil.parseTags(Arrays.asList(VALID_TAG_1, INVALID_TAG)));
- //}
- //
- //@Test
- //public void parseTags_emptyCollection_returnsEmptySet() {
- // assertTrue(ParserUtil.parseTags(Collections.emptyList()).isEmpty());
- //}
- //
- //@Test
- //public void parseTags_collectionWithValidTags_returnsTagSet() {
- // Set actualTagSet = ParserUtil.parseTags(Arrays.asList(VALID_TAG_1, VALID_TAG_2));
- // Set expectedTagSet = new HashSet<>(Arrays.asList(new Tag(VALID_TAG_1), new Tag(VALID_TAG_2)));
- //
- // assertEquals(expectedTagSet, actualTagSet);
- //}
}
diff --git a/src/test/java/seedu/foodrem/logic/parser/generalcommandparser/HelpCommandParserTest.java b/src/test/java/seedu/foodrem/logic/parser/generalcommandparser/HelpCommandParserTest.java
index 48abeaaee74..9d32aa31520 100644
--- a/src/test/java/seedu/foodrem/logic/parser/generalcommandparser/HelpCommandParserTest.java
+++ b/src/test/java/seedu/foodrem/logic/parser/generalcommandparser/HelpCommandParserTest.java
@@ -29,6 +29,9 @@
import seedu.foodrem.logic.commands.tagcommands.TagCommand;
import seedu.foodrem.logic.commands.tagcommands.UntagCommand;
+/**
+ * A class to test the HelpCommandParser.
+ */
class HelpCommandParserTest {
private static final String EXPECTED_ALL_COMMANDS = "exit, help, reset, " // General commands
+ "dec, del, edit, filtertag, find, inc, list, new, rmk, sort, view, " // Item commands
diff --git a/src/test/java/seedu/foodrem/logic/parser/itemcommandparser/DecrementCommandParserTest.java b/src/test/java/seedu/foodrem/logic/parser/itemcommandparser/DecrementCommandParserTest.java
index 0673ea2dafe..ff9c2453bc3 100644
--- a/src/test/java/seedu/foodrem/logic/parser/itemcommandparser/DecrementCommandParserTest.java
+++ b/src/test/java/seedu/foodrem/logic/parser/itemcommandparser/DecrementCommandParserTest.java
@@ -12,6 +12,9 @@
import seedu.foodrem.logic.commands.itemcommands.DecrementCommand;
import seedu.foodrem.model.item.ItemQuantity;
+/**
+ * A class to test the DecrementCommandParser.
+ */
class DecrementCommandParserTest {
private final DecrementCommandParser parser = new DecrementCommandParser();
diff --git a/src/test/java/seedu/foodrem/logic/parser/itemcommandparser/EditCommandParserTest.java b/src/test/java/seedu/foodrem/logic/parser/itemcommandparser/EditCommandParserTest.java
index 2542f60a500..9ab7ec0217a 100644
--- a/src/test/java/seedu/foodrem/logic/parser/itemcommandparser/EditCommandParserTest.java
+++ b/src/test/java/seedu/foodrem/logic/parser/itemcommandparser/EditCommandParserTest.java
@@ -15,9 +15,13 @@
import seedu.foodrem.testutil.MessageToUser;
import seedu.foodrem.testutil.TypicalIndexes;
+/**
+ * A class to test the EditCommandParser.
+ */
public class EditCommandParserTest {
private static final String MESSAGE_INVALID_FORMAT =
String.format(Messages.MESSAGE_INVALID_COMMAND_FORMAT, EditCommand.getUsage());
+ private static final String MESSAGE_NOT_EDITED = "At least one field to edit must be provided.";
private final EditCommandParser parser = new EditCommandParser();
@@ -27,7 +31,7 @@ public void parse_missingParts_failure() {
assertParseFailure(parser, CommandTestUtil.VALID_DESC_ITEM_NAME_POTATOES, MESSAGE_INVALID_FORMAT);
// no field specified
- assertParseFailure(parser, "1", EditCommand.MESSAGE_NOT_EDITED);
+ assertParseFailure(parser, "1", MESSAGE_NOT_EDITED);
// no index and no field specified
assertParseFailure(parser, "", MESSAGE_INVALID_FORMAT);
diff --git a/src/test/java/seedu/foodrem/logic/parser/itemcommandparser/FilterTagCommandParserTest.java b/src/test/java/seedu/foodrem/logic/parser/itemcommandparser/FilterTagCommandParserTest.java
index cd4c89dce98..1b7922b8f35 100644
--- a/src/test/java/seedu/foodrem/logic/parser/itemcommandparser/FilterTagCommandParserTest.java
+++ b/src/test/java/seedu/foodrem/logic/parser/itemcommandparser/FilterTagCommandParserTest.java
@@ -12,6 +12,9 @@
import seedu.foodrem.model.tag.Tag;
import seedu.foodrem.testutil.TagBuilder;
+/**
+ * A class to test the FilterTagCommandParser.
+ */
public class FilterTagCommandParserTest {
private final FilterTagCommandParser parser = new FilterTagCommandParser();
diff --git a/src/test/java/seedu/foodrem/logic/parser/itemcommandparser/IncrementCommandParserTest.java b/src/test/java/seedu/foodrem/logic/parser/itemcommandparser/IncrementCommandParserTest.java
index baa91f70c06..374e5bd1af1 100644
--- a/src/test/java/seedu/foodrem/logic/parser/itemcommandparser/IncrementCommandParserTest.java
+++ b/src/test/java/seedu/foodrem/logic/parser/itemcommandparser/IncrementCommandParserTest.java
@@ -12,6 +12,9 @@
import seedu.foodrem.logic.commands.itemcommands.IncrementCommand;
import seedu.foodrem.model.item.ItemQuantity;
+/**
+ * A class to test the IncrementCommandParser.
+ */
class IncrementCommandParserTest {
private final IncrementCommandParser parser = new IncrementCommandParser();
diff --git a/src/test/java/seedu/foodrem/logic/parser/itemcommandparser/NewCommandParserTest.java b/src/test/java/seedu/foodrem/logic/parser/itemcommandparser/NewCommandParserTest.java
index d384eb0f208..9556bd63b7a 100644
--- a/src/test/java/seedu/foodrem/logic/parser/itemcommandparser/NewCommandParserTest.java
+++ b/src/test/java/seedu/foodrem/logic/parser/itemcommandparser/NewCommandParserTest.java
@@ -13,6 +13,9 @@
import seedu.foodrem.testutil.MessageToUser;
import seedu.foodrem.testutil.TypicalItems;
+/**
+ * A class to test the NewCommandParser.
+ */
public class NewCommandParserTest {
private final NewCommandParser parser = new NewCommandParser();
diff --git a/src/test/java/seedu/foodrem/logic/parser/itemcommandparser/RemarkCommandParserTest.java b/src/test/java/seedu/foodrem/logic/parser/itemcommandparser/RemarkCommandParserTest.java
index 9be03dbdd7d..2f183cf879d 100644
--- a/src/test/java/seedu/foodrem/logic/parser/itemcommandparser/RemarkCommandParserTest.java
+++ b/src/test/java/seedu/foodrem/logic/parser/itemcommandparser/RemarkCommandParserTest.java
@@ -12,6 +12,9 @@
import seedu.foodrem.model.item.ItemRemark;
import seedu.foodrem.testutil.MessageToUser;
+/**
+ * A class to test the RemarkCommandParser.
+ */
class RemarkCommandParserTest {
private final RemarkCommandParser parser = new RemarkCommandParser();
diff --git a/src/test/java/seedu/foodrem/logic/parser/itemcommandparser/SortCommandParserTest.java b/src/test/java/seedu/foodrem/logic/parser/itemcommandparser/SortCommandParserTest.java
index 24e7b2bcc67..7aa13bde226 100644
--- a/src/test/java/seedu/foodrem/logic/parser/itemcommandparser/SortCommandParserTest.java
+++ b/src/test/java/seedu/foodrem/logic/parser/itemcommandparser/SortCommandParserTest.java
@@ -16,6 +16,9 @@
import seedu.foodrem.model.item.itemcomparators.ItemRemarkComparator;
import seedu.foodrem.model.item.itemcomparators.ItemUnitComparator;
+/**
+ * A class to test the SortCommandParser.
+ */
class SortCommandParserTest {
private final SortCommandParser parser = new SortCommandParser();
diff --git a/src/test/java/seedu/foodrem/logic/parser/itemcommandparser/ViewCommandParserTest.java b/src/test/java/seedu/foodrem/logic/parser/itemcommandparser/ViewCommandParserTest.java
index b4230adb50e..40648201289 100644
--- a/src/test/java/seedu/foodrem/logic/parser/itemcommandparser/ViewCommandParserTest.java
+++ b/src/test/java/seedu/foodrem/logic/parser/itemcommandparser/ViewCommandParserTest.java
@@ -9,6 +9,9 @@
import seedu.foodrem.logic.commands.itemcommands.ViewCommand;
+/**
+ * A class to test the ViewCommandParser.
+ */
class ViewCommandParserTest {
private final ViewCommandParser parser = new ViewCommandParser();
diff --git a/src/test/java/seedu/foodrem/logic/parser/tagcommandparser/DeleteTagCommandParserTest.java b/src/test/java/seedu/foodrem/logic/parser/tagcommandparser/DeleteTagCommandParserTest.java
index 1cb6420a927..c4fd8d09f5d 100644
--- a/src/test/java/seedu/foodrem/logic/parser/tagcommandparser/DeleteTagCommandParserTest.java
+++ b/src/test/java/seedu/foodrem/logic/parser/tagcommandparser/DeleteTagCommandParserTest.java
@@ -10,6 +10,9 @@
import seedu.foodrem.logic.commands.tagcommands.DeleteTagCommand;
import seedu.foodrem.testutil.TypicalTags;
+/**
+ * A class to test the DeleteTagCommandParser.
+ */
public class DeleteTagCommandParserTest {
private final DeleteTagCommandParser parser = new DeleteTagCommandParser();
diff --git a/src/test/java/seedu/foodrem/logic/parser/tagcommandparser/NewTagCommandParserTest.java b/src/test/java/seedu/foodrem/logic/parser/tagcommandparser/NewTagCommandParserTest.java
index 1b8633fd5ef..c602b52cbab 100644
--- a/src/test/java/seedu/foodrem/logic/parser/tagcommandparser/NewTagCommandParserTest.java
+++ b/src/test/java/seedu/foodrem/logic/parser/tagcommandparser/NewTagCommandParserTest.java
@@ -15,6 +15,9 @@
import seedu.foodrem.model.tag.Tag;
import seedu.foodrem.testutil.TagBuilder;
+/**
+ * A class to test the NewTagCommandParser.
+ */
public class NewTagCommandParserTest {
private static final int MAX_LENGTH = 20;
private static final String EXCEED_MAX_CHARS_MESSAGE_CONSTRAINTS =
diff --git a/src/test/java/seedu/foodrem/logic/parser/tagcommandparser/RenameTagCommandParserTest.java b/src/test/java/seedu/foodrem/logic/parser/tagcommandparser/RenameTagCommandParserTest.java
index 587a1d0c508..0f05341922d 100644
--- a/src/test/java/seedu/foodrem/logic/parser/tagcommandparser/RenameTagCommandParserTest.java
+++ b/src/test/java/seedu/foodrem/logic/parser/tagcommandparser/RenameTagCommandParserTest.java
@@ -13,6 +13,9 @@
import seedu.foodrem.testutil.TagBuilder;
import seedu.foodrem.testutil.TypicalTags;
+/**
+ * A class to test the RenameTagCommandParser.
+ */
public class RenameTagCommandParserTest {
private final RenameTagCommandParser parser = new RenameTagCommandParser();
diff --git a/src/test/java/seedu/foodrem/logic/parser/tagcommandparser/TagCommandParserTest.java b/src/test/java/seedu/foodrem/logic/parser/tagcommandparser/TagCommandParserTest.java
index 239560d3da0..290e323501c 100644
--- a/src/test/java/seedu/foodrem/logic/parser/tagcommandparser/TagCommandParserTest.java
+++ b/src/test/java/seedu/foodrem/logic/parser/tagcommandparser/TagCommandParserTest.java
@@ -17,6 +17,9 @@
import seedu.foodrem.model.tag.Tag;
import seedu.foodrem.testutil.TagBuilder;
+/**
+ * A class to test the TagCommandParser.
+ */
public class TagCommandParserTest {
private static final String MESSAGE_INVALID_FORMAT =
String.format(MESSAGE_INVALID_COMMAND_FORMAT, TagCommand.getUsage());
diff --git a/src/test/java/seedu/foodrem/logic/parser/tagcommandparser/UntagCommandParserTest.java b/src/test/java/seedu/foodrem/logic/parser/tagcommandparser/UntagCommandParserTest.java
index 6acbee587de..871612f45fe 100644
--- a/src/test/java/seedu/foodrem/logic/parser/tagcommandparser/UntagCommandParserTest.java
+++ b/src/test/java/seedu/foodrem/logic/parser/tagcommandparser/UntagCommandParserTest.java
@@ -17,6 +17,9 @@
import seedu.foodrem.model.tag.Tag;
import seedu.foodrem.testutil.TagBuilder;
+/**
+ * A class to test the UntagCommandParser.
+ */
public class UntagCommandParserTest {
private static final String MESSAGE_INVALID_FORMAT =
String.format(MESSAGE_INVALID_COMMAND_FORMAT, UntagCommand.getUsage());
diff --git a/src/test/java/seedu/foodrem/model/ModelManagerTest.java b/src/test/java/seedu/foodrem/model/ModelManagerTest.java
index 70eae9c6298..f7cef8843e8 100644
--- a/src/test/java/seedu/foodrem/model/ModelManagerTest.java
+++ b/src/test/java/seedu/foodrem/model/ModelManagerTest.java
@@ -19,6 +19,9 @@
import seedu.foodrem.model.item.NameContainsKeywordsPredicate;
import seedu.foodrem.testutil.FoodRemBuilder;
+/**
+ * A class to test the ModelManager.
+ */
public class ModelManagerTest {
private ModelManager modelManager = new ModelManager();
diff --git a/src/test/java/seedu/foodrem/model/item/UniqueItemListTest.java b/src/test/java/seedu/foodrem/model/item/UniqueItemListTest.java
index 110bc52cb2f..082e252593f 100644
--- a/src/test/java/seedu/foodrem/model/item/UniqueItemListTest.java
+++ b/src/test/java/seedu/foodrem/model/item/UniqueItemListTest.java
@@ -18,6 +18,9 @@
import seedu.foodrem.model.item.exceptions.ItemNotFoundException;
import seedu.foodrem.testutil.ItemBuilder;
+/**
+ * A class to test the UniqueItemList.
+ */
public class UniqueItemListTest {
private final UniqueItemList uniqueItemList = new UniqueItemList();
diff --git a/src/test/java/seedu/foodrem/model/item/itemvalidators/ItemBoughtDateValidatorTest.java b/src/test/java/seedu/foodrem/model/item/itemvalidators/ItemBoughtDateValidatorTest.java
index b8b5cb20e15..2f5e56637a5 100644
--- a/src/test/java/seedu/foodrem/model/item/itemvalidators/ItemBoughtDateValidatorTest.java
+++ b/src/test/java/seedu/foodrem/model/item/itemvalidators/ItemBoughtDateValidatorTest.java
@@ -6,6 +6,9 @@
import seedu.foodrem.testutil.MessageToUser;
+/**
+ * A class to test the ItemBoughtDateValidator.
+ */
public class ItemBoughtDateValidatorTest {
/**
* Checks for valid date string formatting.
diff --git a/src/test/java/seedu/foodrem/model/item/itemvalidators/ItemExpiryDateValidatorTest.java b/src/test/java/seedu/foodrem/model/item/itemvalidators/ItemExpiryDateValidatorTest.java
index b6117c925cd..1feede4d664 100644
--- a/src/test/java/seedu/foodrem/model/item/itemvalidators/ItemExpiryDateValidatorTest.java
+++ b/src/test/java/seedu/foodrem/model/item/itemvalidators/ItemExpiryDateValidatorTest.java
@@ -6,6 +6,9 @@
import seedu.foodrem.testutil.MessageToUser;
+/**
+ * A class to test the ItemExpiryDateValidator.
+ */
public class ItemExpiryDateValidatorTest {
/**
* Checks for valid date string formatting.
diff --git a/src/test/java/seedu/foodrem/model/item/itemvalidators/ItemNameValidatorTest.java b/src/test/java/seedu/foodrem/model/item/itemvalidators/ItemNameValidatorTest.java
index 0f9dab4fb0e..2a012b96be3 100644
--- a/src/test/java/seedu/foodrem/model/item/itemvalidators/ItemNameValidatorTest.java
+++ b/src/test/java/seedu/foodrem/model/item/itemvalidators/ItemNameValidatorTest.java
@@ -6,6 +6,9 @@
import seedu.foodrem.testutil.MessageToUser;
+/**
+ * A class to test the ItemNameValidator.
+ */
public class ItemNameValidatorTest {
// TODO: Test for uniqueness of Item Name
diff --git a/src/test/java/seedu/foodrem/model/item/itemvalidators/ItemQuantityValidatorTest.java b/src/test/java/seedu/foodrem/model/item/itemvalidators/ItemQuantityValidatorTest.java
index 1bfcbf55826..f2d50011cf7 100644
--- a/src/test/java/seedu/foodrem/model/item/itemvalidators/ItemQuantityValidatorTest.java
+++ b/src/test/java/seedu/foodrem/model/item/itemvalidators/ItemQuantityValidatorTest.java
@@ -6,6 +6,9 @@
import seedu.foodrem.testutil.MessageToUser;
+/**
+ * A class to test the ItemQuantityValidator.
+ */
public class ItemQuantityValidatorTest {
@Test
public void test_quantityInValidRange() {
diff --git a/src/test/java/seedu/foodrem/model/item/itemvalidators/ItemUnitValidatorTest.java b/src/test/java/seedu/foodrem/model/item/itemvalidators/ItemUnitValidatorTest.java
index 3578f684ed0..d02bdc578ea 100644
--- a/src/test/java/seedu/foodrem/model/item/itemvalidators/ItemUnitValidatorTest.java
+++ b/src/test/java/seedu/foodrem/model/item/itemvalidators/ItemUnitValidatorTest.java
@@ -6,6 +6,9 @@
import seedu.foodrem.testutil.MessageToUser;
+/**
+ * A class to test the ItemUnitValidator.
+ */
public class ItemUnitValidatorTest {
@Test
public void test_nameIsValidLength() {
diff --git a/src/test/java/seedu/foodrem/model/item/itemvalidators/ItemValidatorUtilTest.java b/src/test/java/seedu/foodrem/model/item/itemvalidators/ItemValidatorUtilTest.java
index 6689f84737f..f468c6d8fcf 100644
--- a/src/test/java/seedu/foodrem/model/item/itemvalidators/ItemValidatorUtilTest.java
+++ b/src/test/java/seedu/foodrem/model/item/itemvalidators/ItemValidatorUtilTest.java
@@ -4,6 +4,9 @@
import java.util.function.Supplier;
+/**
+ * A class to test the ItemValidatorUtil.
+ */
public class ItemValidatorUtilTest {
/**
* Asserts that the validation of {@code userInput} by {@code validator} is unsuccessful and the error message
diff --git a/src/test/java/seedu/foodrem/storage/JsonAdaptedItemTest.java b/src/test/java/seedu/foodrem/storage/JsonAdaptedItemTest.java
index e57b157c16e..fce8b6b003e 100644
--- a/src/test/java/seedu/foodrem/storage/JsonAdaptedItemTest.java
+++ b/src/test/java/seedu/foodrem/storage/JsonAdaptedItemTest.java
@@ -20,6 +20,9 @@
import seedu.foodrem.testutil.TypicalItems;
import seedu.foodrem.testutil.TypicalTags;
+/**
+ * A class to test if an item can be converted into a JSON format.
+ */
public class JsonAdaptedItemTest {
private static final String MESSAGE_FOR_INVALID_CHARACTERS_IN_UNIT =
"The item unit should only contain alphanumeric characters, spaces and the following symbols "
@@ -38,6 +41,7 @@ public class JsonAdaptedItemTest {
private static final String MESSAGE_FOR_INVALID_CHARACTERS_IN_REMARKS =
"The item remark should only contain alphanumeric characters, spaces and the following symbols "
+ "[]{}()-+*=.,_'\"^$?@!#%&:;";
+ private static final String MISSING_FIELD_MESSAGE_FORMAT = "Item's %s field is missing!";
private static final String INVALID_NAME = "Po|a|oes\\";
private static final String INVALID_QUANTITY = "1/2";
@@ -89,7 +93,7 @@ public void toModelType_nullName_throwsIllegalArgumentException() {
VALID_PRICE,
VALID_REMARKS,
VALID_TAG_SET);
- String expectedMessage = String.format(JsonAdaptedItem.MISSING_FIELD_MESSAGE_FORMAT,
+ String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT,
ItemName.class.getSimpleName());
assertThrows(IllegalArgumentException.class, expectedMessage, item::toModelType);
}
@@ -119,7 +123,7 @@ public void toModelType_nullQuantity_throwsIllegalArgumentException() {
VALID_PRICE,
VALID_REMARKS,
VALID_TAG_SET);
- String expectedMessage = String.format(JsonAdaptedItem.MISSING_FIELD_MESSAGE_FORMAT,
+ String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT,
ItemQuantity.class.getSimpleName());
assertThrows(IllegalArgumentException.class, expectedMessage, item::toModelType);
}
@@ -148,7 +152,7 @@ public void toModelType_nullUnit_throwsIllegalArgumentException() {
VALID_PRICE,
VALID_REMARKS,
VALID_TAG_SET);
- String expectedMessage = String.format(JsonAdaptedItem.MISSING_FIELD_MESSAGE_FORMAT,
+ String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT,
ItemUnit.class.getSimpleName());
assertThrows(IllegalArgumentException.class, expectedMessage, item::toModelType);
}
@@ -176,7 +180,7 @@ public void toModelType_nullBoughtDate_throwsIllegalArgumentException() {
VALID_PRICE,
VALID_REMARKS,
VALID_TAG_SET);
- String expectedMessage = String.format(JsonAdaptedItem.MISSING_FIELD_MESSAGE_FORMAT,
+ String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT,
ItemBoughtDate.class.getSimpleName());
assertThrows(IllegalArgumentException.class, expectedMessage, item::toModelType);
}
@@ -204,7 +208,7 @@ public void toModelType_nullExpiryDate_throwsIllegalArgumentException() {
VALID_PRICE,
VALID_REMARKS,
VALID_TAG_SET);
- String expectedMessage = String.format(JsonAdaptedItem.MISSING_FIELD_MESSAGE_FORMAT,
+ String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT,
ItemExpiryDate.class.getSimpleName());
assertThrows(IllegalArgumentException.class, expectedMessage, item::toModelType);
}
@@ -232,7 +236,7 @@ public void toModelType_nullPrice_throwsIllegalArgumentException() {
null,
VALID_REMARKS,
VALID_TAG_SET);
- String expectedMessage = String.format(JsonAdaptedItem.MISSING_FIELD_MESSAGE_FORMAT,
+ String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT,
ItemPrice.class.getSimpleName());
assertThrows(IllegalArgumentException.class, expectedMessage, item::toModelType);
}
@@ -260,7 +264,7 @@ public void toModelType_nullRemarks_throwsIllegalArgumentException() {
VALID_PRICE,
null,
VALID_TAG_SET);
- String expectedMessage = String.format(JsonAdaptedItem.MISSING_FIELD_MESSAGE_FORMAT,
+ String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT,
ItemRemark.class.getSimpleName());
assertThrows(IllegalArgumentException.class, expectedMessage, item::toModelType);
}
diff --git a/src/test/java/seedu/foodrem/storage/JsonFoodRemStorageTest.java b/src/test/java/seedu/foodrem/storage/JsonFoodRemStorageTest.java
index d72cacff108..45baaf15b50 100644
--- a/src/test/java/seedu/foodrem/storage/JsonFoodRemStorageTest.java
+++ b/src/test/java/seedu/foodrem/storage/JsonFoodRemStorageTest.java
@@ -19,6 +19,9 @@
import seedu.foodrem.model.ReadOnlyFoodRem;
import seedu.foodrem.testutil.TypicalTags;
+/**
+ * A class to test JsonFoodRemStorage.
+ */
public class JsonFoodRemStorageTest {
private static final Path TEST_DATA_FOLDER = Paths.get("src", "test", "data", "JsonFoodRemStorageTest");
diff --git a/src/test/java/seedu/foodrem/storage/JsonSerializableFoodRemTest.java b/src/test/java/seedu/foodrem/storage/JsonSerializableFoodRemTest.java
index 13abef2eb4d..d9c737e4aa5 100644
--- a/src/test/java/seedu/foodrem/storage/JsonSerializableFoodRemTest.java
+++ b/src/test/java/seedu/foodrem/storage/JsonSerializableFoodRemTest.java
@@ -12,6 +12,9 @@
import seedu.foodrem.model.FoodRem;
import seedu.foodrem.testutil.TypicalFoodRem;
+/**
+ * A class to test JsonSerializableFoodRem.
+ */
public class JsonSerializableFoodRemTest {
private static final Path TEST_DATA_FOLDER = Paths
.get("src", "test", "data", "JsonSerializableFoodRemTest");
@@ -21,8 +24,6 @@ public class JsonSerializableFoodRemTest {
.resolve("invalidItemFoodRem.json");
private static final Path DUPLICATE_ITEM_FILE = TEST_DATA_FOLDER
.resolve("duplicateItemFoodRem.json");
- private static final Path DUPLICATE_TAG_FILE = TEST_DATA_FOLDER
- .resolve("duplicateTagFoodRem.json");
private static final Path INVALID_TAG_FILE = TEST_DATA_FOLDER
.resolve("invalidTagFoodRem.json");
private static final Path TYPICAL_FOODREM_FILE = TEST_DATA_FOLDER
diff --git a/src/test/java/seedu/foodrem/storage/JsonUserPrefsStorageTest.java b/src/test/java/seedu/foodrem/storage/JsonUserPrefsStorageTest.java
index 980611ee7ed..2cd281aeb63 100644
--- a/src/test/java/seedu/foodrem/storage/JsonUserPrefsStorageTest.java
+++ b/src/test/java/seedu/foodrem/storage/JsonUserPrefsStorageTest.java
@@ -16,6 +16,9 @@
import seedu.foodrem.commons.exceptions.DataConversionException;
import seedu.foodrem.model.UserPrefs;
+/**
+ * A class to test JsonUserPrefsStorage.
+ */
public class JsonUserPrefsStorageTest {
private static final Path TEST_DATA_FOLDER = Paths.get("src", "test", "data", "JsonUserPrefsStorageTest");
diff --git a/src/test/java/seedu/foodrem/storage/StorageManagerTest.java b/src/test/java/seedu/foodrem/storage/StorageManagerTest.java
index c6b9cf29603..942736f81a1 100644
--- a/src/test/java/seedu/foodrem/storage/StorageManagerTest.java
+++ b/src/test/java/seedu/foodrem/storage/StorageManagerTest.java
@@ -15,6 +15,9 @@
import seedu.foodrem.model.ReadOnlyFoodRem;
import seedu.foodrem.model.UserPrefs;
+/**
+ * A class to test StorageManager.
+ */
public class StorageManagerTest {
@TempDir
public Path testFolder;
diff --git a/src/test/java/seedu/foodrem/testutil/EditItemDescriptorBuilder.java b/src/test/java/seedu/foodrem/testutil/EditItemDescriptorBuilder.java
index 905cc14366b..a564564dc68 100644
--- a/src/test/java/seedu/foodrem/testutil/EditItemDescriptorBuilder.java
+++ b/src/test/java/seedu/foodrem/testutil/EditItemDescriptorBuilder.java
@@ -16,10 +16,16 @@
public class EditItemDescriptorBuilder {
private final EditItemDescriptor descriptor;
+ /**
+ * Constructs an EditItemDescriptorBuilder.
+ */
public EditItemDescriptorBuilder() {
descriptor = new EditItemDescriptor();
}
+ /**
+ * Constructs an EditItemDescriptorBuilder.
+ */
public EditItemDescriptorBuilder(EditItemDescriptor descriptor) {
this.descriptor = new EditItemDescriptor(descriptor);
}
@@ -94,6 +100,9 @@ public EditItemDescriptorBuilder withItemRemarks(String remarks) {
return this;
}
+ /**
+ * Returns an EditItemDescriptor.
+ */
public EditItemDescriptor build() {
return descriptor;
}
diff --git a/src/test/java/seedu/foodrem/testutil/ItemUtil.java b/src/test/java/seedu/foodrem/testutil/ItemUtil.java
index 77e1841c1fc..75809b03d8a 100644
--- a/src/test/java/seedu/foodrem/testutil/ItemUtil.java
+++ b/src/test/java/seedu/foodrem/testutil/ItemUtil.java
@@ -56,16 +56,6 @@ public static String getEditItemDescriptorDetails(EditItemDescriptor descriptor)
.ifPresent(price -> sb.append(CliSyntax.PREFIX_ITEM_PRICE).append(price).append(" "));
descriptor.getItemRemarks()
.ifPresent(remarks -> sb.append(CliSyntax.PREFIX_ITEM_REMARKS).append(remarks).append(" "));
- // TODO: Check if we can delete this.
- //if (descriptor.getTags().isPresent()) {
- // Set tags = descriptor.getTags().get();
- // if (tags.isEmpty()) {
- // sb.append(PREFIX_TAG);
- // } else {
- // tags.forEach(s -> sb.append(PREFIX_TAG).append(s.tagName).append(" "));
- // }
- //}
return sb.toString();
-
}
}
diff --git a/src/test/java/seedu/foodrem/ui/UiPartTest.java b/src/test/java/seedu/foodrem/ui/UiPartTest.java
index 692f2322d14..75d567b4d9d 100644
--- a/src/test/java/seedu/foodrem/ui/UiPartTest.java
+++ b/src/test/java/seedu/foodrem/ui/UiPartTest.java
@@ -13,6 +13,9 @@
import javafx.fxml.FXML;
import seedu.foodrem.MainApp;
+/**
+ * A test object which to test UiPart.
+ */
public class UiPartTest {
private static final String MISSING_FILE_PATH = "UiPartTest/missingFile.fxml";
private static final String INVALID_FILE_PATH = "UiPartTest/invalidFile.fxml";
From 2c03f41ab36c697263427b9fc56769abc3b66cef Mon Sep 17 00:00:00 2001
From: Tan Yi Xian <>
Date: Sun, 6 Nov 2022 14:45:51 +0800
Subject: [PATCH 02/25] Add javadoc headers for exceptions
---
.../commons/exceptions/DataConversionException.java | 3 +++
.../commons/exceptions/ItemStorageFullException.java | 7 +++++++
.../foodrem/commons/exceptions/StorageFullException.java | 3 +++
.../commons/exceptions/TagStorageFullException.java | 7 +++++++
4 files changed, 20 insertions(+)
diff --git a/src/main/java/seedu/foodrem/commons/exceptions/DataConversionException.java b/src/main/java/seedu/foodrem/commons/exceptions/DataConversionException.java
index 1ace34890a1..ff4a4349a81 100644
--- a/src/main/java/seedu/foodrem/commons/exceptions/DataConversionException.java
+++ b/src/main/java/seedu/foodrem/commons/exceptions/DataConversionException.java
@@ -4,6 +4,9 @@
* Represents an error during conversion of data from one format to another
*/
public class DataConversionException extends Exception {
+ /**
+ * Constructs a DataConversionException.
+ */
public DataConversionException(Exception cause) {
super(cause);
}
diff --git a/src/main/java/seedu/foodrem/commons/exceptions/ItemStorageFullException.java b/src/main/java/seedu/foodrem/commons/exceptions/ItemStorageFullException.java
index e9823f80859..82469009610 100644
--- a/src/main/java/seedu/foodrem/commons/exceptions/ItemStorageFullException.java
+++ b/src/main/java/seedu/foodrem/commons/exceptions/ItemStorageFullException.java
@@ -4,9 +4,16 @@
* Represents an error when more items are added when the storage is full.
*/
public class ItemStorageFullException extends StorageFullException {
+ /**
+ * Constructs an ItemStorageFullException.
+ */
public ItemStorageFullException(int maxNumberOfItems) {
super(String.format("The item storage is full. FoodRem can only hold up to %s items.", maxNumberOfItems));
}
+
+ /**
+ * Constructs an ItemStorageFullException.
+ */
public ItemStorageFullException(String message) {
super(message);
}
diff --git a/src/main/java/seedu/foodrem/commons/exceptions/StorageFullException.java b/src/main/java/seedu/foodrem/commons/exceptions/StorageFullException.java
index cd100d70c92..dc3d855f2ba 100644
--- a/src/main/java/seedu/foodrem/commons/exceptions/StorageFullException.java
+++ b/src/main/java/seedu/foodrem/commons/exceptions/StorageFullException.java
@@ -4,6 +4,9 @@
* Represents an error when the storage is full.
*/
public class StorageFullException extends RuntimeException {
+ /**
+ * Constructs a StorageFullException.
+ */
public StorageFullException(String message) {
super(message);
}
diff --git a/src/main/java/seedu/foodrem/commons/exceptions/TagStorageFullException.java b/src/main/java/seedu/foodrem/commons/exceptions/TagStorageFullException.java
index 24c42c27ff9..330e98e5dd3 100644
--- a/src/main/java/seedu/foodrem/commons/exceptions/TagStorageFullException.java
+++ b/src/main/java/seedu/foodrem/commons/exceptions/TagStorageFullException.java
@@ -4,9 +4,16 @@
* Represents an error when more items are added when the storage is full.
*/
public class TagStorageFullException extends StorageFullException {
+ /**
+ * Constructs a TagStorageFullException.
+ */
public TagStorageFullException(int maxNumberOfTags) {
super(String.format("The tag storage is full. FoodRem can only hold up to %s tags.", maxNumberOfTags));
}
+
+ /**
+ * Constructs a TagStorageFullException.
+ */
public TagStorageFullException(String message) {
super(message);
}
From da0dd482b757db34d8c550c8f528b1c5b042e5f8 Mon Sep 17 00:00:00 2001
From: Tan Yi Xian <>
Date: Sun, 6 Nov 2022 14:46:37 +0800
Subject: [PATCH 03/25] Add linebreak to conform to Markdown code quality
---
docs/DeveloperGuide.md | 1 +
docs/_ug/commands/GeneralCommands.md | 1 +
2 files changed, 2 insertions(+)
diff --git a/docs/DeveloperGuide.md b/docs/DeveloperGuide.md
index 3ba1169684d..e7a42cb6d5d 100644
--- a/docs/DeveloperGuide.md
+++ b/docs/DeveloperGuide.md
@@ -43,6 +43,7 @@ Here are some links to other documentations you might find useful:
## Requirements
This section shares with you useful information regarding the non-technical aspects of development. This includes:
+
1. [Product Scope](#product-scope)
1. [User Stories](#user-stories)
1. [Use Cases](#use-cases)
diff --git a/docs/_ug/commands/GeneralCommands.md b/docs/_ug/commands/GeneralCommands.md
index e8b635508c2..b345d888eb9 100644
--- a/docs/_ug/commands/GeneralCommands.md
+++ b/docs/_ug/commands/GeneralCommands.md
@@ -8,6 +8,7 @@
```note
COMMAND_WORD is strictly any of the following:
+
* exit
* help
* reset
From 0c01a8ab23361ad111fcd5bac0f0aa1ecf71c2f7 Mon Sep 17 00:00:00 2001
From: Tan Yi Xian <>
Date: Sun, 6 Nov 2022 14:47:22 +0800
Subject: [PATCH 04/25] Convert default fields to private in ItemBuilder
---
.../seedu/foodrem/testutil/ItemBuilder.java | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/src/test/java/seedu/foodrem/testutil/ItemBuilder.java b/src/test/java/seedu/foodrem/testutil/ItemBuilder.java
index 20dc0db7262..13de6bb1491 100644
--- a/src/test/java/seedu/foodrem/testutil/ItemBuilder.java
+++ b/src/test/java/seedu/foodrem/testutil/ItemBuilder.java
@@ -17,13 +17,13 @@
* A utility class to help with building Item objects.
*/
public class ItemBuilder {
- public static final String DEFAULT_NAME = "NONE";
- public static final String DEFAULT_QUANTITY = "0";
- public static final String DEFAULT_ITEM_UNIT = "";
- public static final String DEFAULT_BOUGHT_DATE = "";
- public static final String DEFAULT_EXPIRY_DATE = "";
- public static final String DEFAULT_PRICE = "";
- public static final String DEFAULT_REMARKS = "";
+ private static final String DEFAULT_NAME = "NONE";
+ private static final String DEFAULT_QUANTITY = "0";
+ private static final String DEFAULT_ITEM_UNIT = "";
+ private static final String DEFAULT_BOUGHT_DATE = "";
+ private static final String DEFAULT_EXPIRY_DATE = "";
+ private static final String DEFAULT_PRICE = "";
+ private static final String DEFAULT_REMARKS = "";
// Identity fields
private ItemName name;
@@ -130,6 +130,9 @@ public ItemBuilder withTags(String... tagNames) {
return this;
}
+ /**
+ * Returns the item to be build.
+ */
public Item build() {
return new Item(name, quantity, unit, boughtDate, expiryDate, price, remarks, tags);
}
From 387785aba60b3620841398b85547232702eb9f6f Mon Sep 17 00:00:00 2001
From: Tan Yi Xian <>
Date: Sun, 6 Nov 2022 14:48:57 +0800
Subject: [PATCH 05/25] Apply SLAP to ItemCard constructor
---
src/main/java/seedu/foodrem/ui/ItemCard.java | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/src/main/java/seedu/foodrem/ui/ItemCard.java b/src/main/java/seedu/foodrem/ui/ItemCard.java
index 91a12ef4596..184fe27ef66 100644
--- a/src/main/java/seedu/foodrem/ui/ItemCard.java
+++ b/src/main/java/seedu/foodrem/ui/ItemCard.java
@@ -3,6 +3,7 @@
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
+import java.util.Set;
import javafx.fxml.FXML;
import javafx.scene.control.Label;
@@ -53,8 +54,14 @@ public ItemCard(Item item, int displayedIndex) {
quantity.setText(ItemView.buildItemQuantityAndUnitStringFrom(item));
quantity.setTextAlignment(TextAlignment.RIGHT);
+ createTagsUi(item.getTagSet());
+ }
- final List tagList = new ArrayList<>(item.getTagSet());
+ /**
+ * Creates a tag ui to display the tags.
+ */
+ private void createTagsUi(Set tagSet) {
+ final List tagList = new ArrayList<>(tagSet);
tagList.sort(Comparator.comparing(Tag::getName));
int currentLength = 0;
@@ -69,7 +76,7 @@ public ItemCard(Item item, int displayedIndex) {
tags.getChildren().add(TagView.from(tag, true));
}
- final int size = item.getTagSet().size();
+ final int size = tagSet.size();
if (size > currentIndex) {
final Label overflowLabel = new Label(String.format("+%d more...", size - currentIndex));
overflowLabel.getStyleClass().add("tags-overflow-label");
From f248c6bc898742628c0a50d54d46f69d5fd18c77 Mon Sep 17 00:00:00 2001
From: Tan Yi Xian <>
Date: Sun, 6 Nov 2022 14:53:35 +0800
Subject: [PATCH 06/25] Add javadocs to item and item field classes
---
.../java/seedu/foodrem/model/item/Item.java | 34 ++++++++++++++++++-
.../seedu/foodrem/model/item/ItemDate.java | 13 +++++--
.../seedu/foodrem/model/item/ItemPrice.java | 5 ++-
.../foodrem/model/item/ItemQuantity.java | 3 ++
4 files changed, 51 insertions(+), 4 deletions(-)
diff --git a/src/main/java/seedu/foodrem/model/item/Item.java b/src/main/java/seedu/foodrem/model/item/Item.java
index a1feab25f87..0b3a2bc679d 100644
--- a/src/main/java/seedu/foodrem/model/item/Item.java
+++ b/src/main/java/seedu/foodrem/model/item/Item.java
@@ -74,6 +74,10 @@ public Item(ItemName name,
/**
* Creates and returns an {@code Item} with {@code tags}.
+ *
+ * @param item the item to be created.
+ * @param tags the tags to be added to the item.
+ * @return an item with the tags provided.
*/
public static Item createItemWithTags(Item item, Set tags) {
requireNonNull(item);
@@ -90,30 +94,51 @@ public static Item createItemWithTags(Item item, Set tags) {
);
}
+ /**
+ * Returns the item name.
+ */
public ItemName getName() {
return name;
}
+ /**
+ * Returns the item quantity.
+ */
public ItemQuantity getQuantity() {
return quantity;
}
+ /**
+ * Returns the item unit.
+ */
public ItemUnit getUnit() {
return unit;
}
+ /**
+ * Returns the item bought date.
+ */
public ItemBoughtDate getBoughtDate() {
return boughtDate;
}
+ /**
+ * Returns the item expiry date.
+ */
public ItemExpiryDate getExpiryDate() {
return expiryDate;
}
+ /**
+ * Returns the item price.
+ */
public ItemPrice getPrice() {
return price;
}
+ /**
+ * Returns the item remarks.
+ */
public ItemRemark getRemarks() {
return remarks;
}
@@ -137,6 +162,8 @@ public boolean hasNonZeroQuantity() {
}
/**
+ * Returns the item value.
+ *
* @return The total value of purchasing the specified units of the item.
*/
public double getItemValue() {
@@ -144,8 +171,13 @@ public double getItemValue() {
return price.getItemPrice() * quantity.getItemQuantity();
}
- // Instantiate new set to preserve immutability of item.
+ /**
+ * Returns the tags of the item.
+ *
+ * @return a new set containing the tags of this item.
+ */
public Set getTagSet() {
+ // Instantiate new set to preserve immutability of item.
return new HashSet<>(tagSet);
}
diff --git a/src/main/java/seedu/foodrem/model/item/ItemDate.java b/src/main/java/seedu/foodrem/model/item/ItemDate.java
index 2877827b0ee..8c6fc210bbc 100644
--- a/src/main/java/seedu/foodrem/model/item/ItemDate.java
+++ b/src/main/java/seedu/foodrem/model/item/ItemDate.java
@@ -15,14 +15,23 @@ public abstract class ItemDate {
private final LocalDate date;
+ /**
+ * Constructs an ItemDate.
+ */
protected ItemDate(LocalDate date) {
this.date = date;
}
+ /**
+ * Returns the local date.
+ */
public LocalDate getDate() {
return date;
}
+ /**
+ * Compares the itemDate to another itemDate.
+ */
public int compareTo(ItemDate other) {
return date.compareTo(other.date);
}
@@ -60,8 +69,8 @@ public boolean isAfterDate(ItemDate itemDate) {
@Override
public boolean equals(Object other) {
return other == this
- && other instanceof ItemDate
- && date.equals(((ItemDate) other).date);
+ || (other instanceof ItemDate
+ && date.equals(((ItemDate) other).date));
}
/**
diff --git a/src/main/java/seedu/foodrem/model/item/ItemPrice.java b/src/main/java/seedu/foodrem/model/item/ItemPrice.java
index e71f5b7a26a..94b99a9c3f7 100644
--- a/src/main/java/seedu/foodrem/model/item/ItemPrice.java
+++ b/src/main/java/seedu/foodrem/model/item/ItemPrice.java
@@ -17,7 +17,7 @@ public class ItemPrice {
private final double itemPrice;
/**
- * {@inheritDoc}
+ * Constructs an ItemPrice.
*/
public ItemPrice(String itemPriceString) {
requireNonNull(itemPriceString);
@@ -29,6 +29,9 @@ public ItemPrice(String itemPriceString) {
itemPrice = Double.parseDouble(itemPriceString);
}
+ /**
+ * Returns the itemPrice.
+ */
public double getItemPrice() {
return itemPrice;
}
diff --git a/src/main/java/seedu/foodrem/model/item/ItemQuantity.java b/src/main/java/seedu/foodrem/model/item/ItemQuantity.java
index a094c93a958..d18cb8d10ed 100644
--- a/src/main/java/seedu/foodrem/model/item/ItemQuantity.java
+++ b/src/main/java/seedu/foodrem/model/item/ItemQuantity.java
@@ -30,6 +30,9 @@ public ItemQuantity(String itemQuantityString) {
itemQuantity = Double.parseDouble(itemQuantityString);
}
+ /**
+ * Returns the itemQuantity.
+ */
public double getItemQuantity() {
return itemQuantity;
}
From fe68c4c35dcd1a18a6cb25c85f27f428233abc73 Mon Sep 17 00:00:00 2001
From: Tan Yi Xian <>
Date: Sun, 6 Nov 2022 14:56:14 +0800
Subject: [PATCH 07/25] Add javadocs to commands
---
.../commands/generalcommands/ExitCommand.java | 8 ++
.../commands/generalcommands/HelpCommand.java | 31 +++++-
.../generalcommands/ResetCommand.java | 9 ++
.../itemcommands/DecrementCommand.java | 11 ++
.../commands/itemcommands/DeleteCommand.java | 8 ++
.../commands/itemcommands/EditCommand.java | 104 +++++++++++++++++-
.../itemcommands/FilterTagCommand.java | 20 +++-
.../commands/itemcommands/FindCommand.java | 14 +++
.../itemcommands/IncrementCommand.java | 19 +++-
.../commands/itemcommands/ListCommand.java | 8 ++
.../commands/itemcommands/NewCommand.java | 11 ++
.../commands/itemcommands/RemarkCommand.java | 12 ++
.../commands/itemcommands/SortCommand.java | 14 +++
.../commands/itemcommands/ViewCommand.java | 19 +++-
.../commands/statscommands/StatsCommand.java | 5 +
.../tagcommands/DeleteTagCommand.java | 5 +
.../commands/tagcommands/NewTagCommand.java | 5 +
.../tagcommands/RenameTagCommand.java | 5 +
.../commands/tagcommands/TagCommand.java | 5 +
.../commands/tagcommands/UntagCommand.java | 5 +
20 files changed, 298 insertions(+), 20 deletions(-)
diff --git a/src/main/java/seedu/foodrem/logic/commands/generalcommands/ExitCommand.java b/src/main/java/seedu/foodrem/logic/commands/generalcommands/ExitCommand.java
index ab458c2d6fb..40dffb04b5e 100644
--- a/src/main/java/seedu/foodrem/logic/commands/generalcommands/ExitCommand.java
+++ b/src/main/java/seedu/foodrem/logic/commands/generalcommands/ExitCommand.java
@@ -10,6 +10,9 @@
* Terminates the program.
*/
public class ExitCommand extends Command {
+ /**
+ * {@inheritDoc}
+ */
@Override
public CommandResult execute(Model model) {
return new CommandResult<>() {
@@ -44,6 +47,11 @@ public boolean equals(Object other) {
};
}
+ /**
+ * Returns a string representing how to use the command.
+ *
+ * @return a string representing how to use the command.
+ */
public static String getUsage() {
return EXIT_COMMAND.getUsage();
}
diff --git a/src/main/java/seedu/foodrem/logic/commands/generalcommands/HelpCommand.java b/src/main/java/seedu/foodrem/logic/commands/generalcommands/HelpCommand.java
index 6cf7d46cc95..1f9f8f39ef0 100644
--- a/src/main/java/seedu/foodrem/logic/commands/generalcommands/HelpCommand.java
+++ b/src/main/java/seedu/foodrem/logic/commands/generalcommands/HelpCommand.java
@@ -9,7 +9,7 @@
import seedu.foodrem.model.Model;
/**
- * Format full help instructions for every command for display.
+ * Formats full help instructions for every command for display.
*/
public class HelpCommand extends Command {
public static final String DEFAULT_HELP_MESSAGE = "Please refer to the user guide.";
@@ -38,27 +38,45 @@ public HelpCommand(String message) {
this.message = message;
}
+ /**
+ * Returns a command help message.
+ */
public static String getCommandHelpMessage(CommandType command) {
return String.format(HELP_FORMAT_SPECIFIC, command.getUsage());
}
+ /**
+ * Returns a general help message.
+ */
public static String getGeneralHelpMessage() {
return HELP_FORMAT_GENERAL;
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public CommandResult execute(Model model) {
return new CommandResult<>() {
+ /**
+ * {@inheritDoc}
+ */
@Override
public String getOutput() {
return SHOWING_HELP_MESSAGE;
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public boolean shouldShowHelp() {
return true;
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public String getHelpText() {
assert message != null;
@@ -66,6 +84,9 @@ public String getHelpText() {
}
// TODO: Test this
+ /**
+ * {@inheritDoc}
+ */
@Override
public boolean equals(Object other) {
if (other == this) {
@@ -87,10 +108,18 @@ && getHelpText().equals(asType.getHelpText())
};
}
+ /**
+ * Returns a string representing how to use the command.
+ *
+ * @return a string representing how to use the command.
+ */
public static String getUsage() {
return HELP_COMMAND.getUsage();
}
+ /**
+ * Returns {@code true} if both {@link HelpCommand} are equal.
+ */
@Override
public boolean equals(Object other) {
return other == this
diff --git a/src/main/java/seedu/foodrem/logic/commands/generalcommands/ResetCommand.java b/src/main/java/seedu/foodrem/logic/commands/generalcommands/ResetCommand.java
index ef156c50d14..230b8d29763 100644
--- a/src/main/java/seedu/foodrem/logic/commands/generalcommands/ResetCommand.java
+++ b/src/main/java/seedu/foodrem/logic/commands/generalcommands/ResetCommand.java
@@ -12,6 +12,10 @@
* Resets FoodRem.
*/
public class ResetCommand extends Command {
+
+ /**
+ * {@inheritDoc}
+ */
@Override
public CommandResult execute(Model model) {
requireNonNull(model);
@@ -19,6 +23,11 @@ public CommandResult execute(Model model) {
return CommandResult.from("FoodRem has been reset!");
}
+ /**
+ * Returns a string representing how to use the command.
+ *
+ * @return a string representing how to use the command.
+ */
public static String getUsage() {
return RESET_COMMAND.getUsage();
}
diff --git a/src/main/java/seedu/foodrem/logic/commands/itemcommands/DecrementCommand.java b/src/main/java/seedu/foodrem/logic/commands/itemcommands/DecrementCommand.java
index 31287cbec95..31b55b29006 100644
--- a/src/main/java/seedu/foodrem/logic/commands/itemcommands/DecrementCommand.java
+++ b/src/main/java/seedu/foodrem/logic/commands/itemcommands/DecrementCommand.java
@@ -59,6 +59,9 @@ private static Item createDecrementedItem(Item itemToDecrement, ItemQuantity qua
itemToDecrement.getTagSet());
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public CommandResult execute(Model model) throws CommandException {
requireNonNull(model);
@@ -76,6 +79,9 @@ public CommandResult execute(Model model) throws CommandExcepti
"Decremented successfully and updated item as follows:"));
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public boolean equals(Object other) {
return other == this
@@ -84,6 +90,11 @@ public boolean equals(Object other) {
&& quantity.equals(((DecrementCommand) other).quantity));
}
+ /**
+ * Returns a string representing how to use the command.
+ *
+ * @return a string representing how to use the command.
+ */
public static String getUsage() {
return DECREMENT_COMMAND.getUsage();
}
diff --git a/src/main/java/seedu/foodrem/logic/commands/itemcommands/DeleteCommand.java b/src/main/java/seedu/foodrem/logic/commands/itemcommands/DeleteCommand.java
index 6dd4da8e24d..311d190e165 100644
--- a/src/main/java/seedu/foodrem/logic/commands/itemcommands/DeleteCommand.java
+++ b/src/main/java/seedu/foodrem/logic/commands/itemcommands/DeleteCommand.java
@@ -24,6 +24,9 @@ public DeleteCommand(Index index) {
this.index = index;
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public CommandResult execute(Model model) throws CommandException {
requireNonNull(model);
@@ -39,6 +42,11 @@ public CommandResult execute(Model model) throws CommandExcepti
"Successfully deleted the following item:"));
}
+ /**
+ * Returns a string representing how to use the command.
+ *
+ * @return a string representing how to use the command.
+ */
public static String getUsage() {
return DELETE_COMMAND.getUsage();
}
diff --git a/src/main/java/seedu/foodrem/logic/commands/itemcommands/EditCommand.java b/src/main/java/seedu/foodrem/logic/commands/itemcommands/EditCommand.java
index 223bfedfa18..3e88d9904ee 100644
--- a/src/main/java/seedu/foodrem/logic/commands/itemcommands/EditCommand.java
+++ b/src/main/java/seedu/foodrem/logic/commands/itemcommands/EditCommand.java
@@ -29,16 +29,13 @@
* Edits the details of an existing item in FoodRem.
*/
public class EditCommand extends Command {
- // Workaround checkstyle violation
- // TODO: FIX ME: Make this implementation detail private
- public static final String MESSAGE_NOT_EDITED = "At least one field to edit must be provided.";
- // TODO: FIX ME: Make this implementation detail private
- public static final String MESSAGE_DUPLICATE_ITEM = "This item already exists in FoodRem.";
-
+ private static final String MESSAGE_DUPLICATE_ITEM = "This item already exists in FoodRem.";
private final EditItemDescriptor editItemDescriptor;
private final Index index;
/**
+ * Constructs an EditCommand object.
+ *
* @param index of the item in the filtered item list to edit
* @param editItemDescriptor details to edit the item with
*/
@@ -53,6 +50,10 @@ public EditCommand(Index index, EditItemDescriptor editItemDescriptor) {
/**
* Creates and returns a {@code Item} with the details of {@code itemToEdit}
* edited with {@code editItemDescriptor}.
+ *
+ * @param itemToEdit the item to be edited.
+ * @param editItemDescriptor the descriptor of how the item should be edited.
+ * @return an item which is edited.
*/
private static Item createEditedItem(Item itemToEdit, EditItemDescriptor editItemDescriptor) {
assert itemToEdit != null;
@@ -76,6 +77,9 @@ private static Item createEditedItem(Item itemToEdit, EditItemDescriptor editIte
tagSet);
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public CommandResult execute(Model model) throws CommandException {
requireNonNull(model);
@@ -97,10 +101,18 @@ public CommandResult execute(Model model) throws CommandExcepti
"Item successfully edited with the following values:"));
}
+ /**
+ * Returns a string representing how to use the command.
+ *
+ * @return a string representing how to use the command.
+ */
public static String getUsage() {
return EDIT_COMMAND.getUsage();
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public boolean equals(Object other) {
if (other == this) {
@@ -128,12 +140,17 @@ public static class EditItemDescriptor {
private ItemPrice price;
private ItemRemark remarks;
+ /**
+ * Constructs an EditItemDescriptor.
+ */
public EditItemDescriptor() {
}
/**
* Copy constructor.
* A defensive copy of {@code tags} is used internally.
+ *
+ * @param toCopy the descriptor of the item to copy.
*/
public EditItemDescriptor(EditItemDescriptor toCopy) {
setItemName(toCopy.name);
@@ -147,67 +164,142 @@ public EditItemDescriptor(EditItemDescriptor toCopy) {
/**
* Returns {@code true} if at least one field is edited.
+ *
+ * @return true if at least one field is edited, false otherwise.
*/
public boolean isAnyFieldEdited() {
return CollectionUtil.isAnyNonNull(name, quantity, unit, boughtDate, expiryDate, price, remarks);
}
+ /**
+ * Returns an optional item name.
+ *
+ * @return an optional item name.
+ */
public Optional getItemName() {
return Optional.ofNullable(name);
}
+ /**
+ * Sets the item name of the descriptor.
+ *
+ * @param name the item name.
+ */
public void setItemName(ItemName name) {
this.name = name;
}
+ /**
+ * Returns an optional item quantity.
+ *
+ * @return an optional item quantity.
+ */
public Optional getItemQuantity() {
return Optional.ofNullable(quantity);
}
+ /**
+ * Sets the item quantity of the descriptor.
+ *
+ * @param quantity the item quantity.
+ */
public void setItemQuantity(ItemQuantity quantity) {
this.quantity = quantity;
}
+ /**
+ * Returns an optional item unit.
+ *
+ * @return an optional item unit.
+ */
public Optional getItemUnit() {
return Optional.ofNullable(unit);
}
+ /**
+ * Sets the item unit of the descriptor.
+ *
+ * @param unit the item unit.
+ */
public void setItemUnit(ItemUnit unit) {
this.unit = unit;
}
+ /**
+ * Returns an optional item bought date.
+ *
+ * @return an optional item bought date.
+ */
public Optional getItemBoughtDate() {
return Optional.ofNullable(boughtDate);
}
+ /**
+ * Sets the item bought date of the descriptor.
+ *
+ * @param boughtDate the item bought date.
+ */
public void setItemBoughtDate(ItemBoughtDate boughtDate) {
this.boughtDate = boughtDate;
}
+ /**
+ * Returns an optional item expiry date.
+ *
+ * @return an optional item expiry date.
+ */
public Optional getItemExpiryDate() {
return Optional.ofNullable(expiryDate);
}
+ /**
+ * Sets the item expiry date of the descriptor.
+ *
+ * @param expiryDate the item expiry date.
+ */
public void setItemExpiryDate(ItemExpiryDate expiryDate) {
this.expiryDate = expiryDate;
}
+ /**
+ * Returns an optional item price.
+ *
+ * @return an optional item price.
+ */
public Optional getItemPrice() {
return Optional.ofNullable(price);
}
+ /**
+ * Sets the item price of the descriptor.
+ *
+ * @param price the item price.
+ */
public void setItemPrice(ItemPrice price) {
this.price = price;
}
+ /**
+ * Returns an optional item remark.
+ *
+ * @return an optional item remark.
+ */
public Optional getItemRemarks() {
return Optional.ofNullable(remarks);
}
+ /**
+ * Sets the item remark of the descriptor.
+ *
+ * @param remarks the item remarks.
+ */
public void setItemRemarks(ItemRemark remarks) {
this.remarks = remarks;
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public boolean equals(Object other) {
if (other == this) {
diff --git a/src/main/java/seedu/foodrem/logic/commands/itemcommands/FilterTagCommand.java b/src/main/java/seedu/foodrem/logic/commands/itemcommands/FilterTagCommand.java
index 9c7f431b865..035d47326ea 100644
--- a/src/main/java/seedu/foodrem/logic/commands/itemcommands/FilterTagCommand.java
+++ b/src/main/java/seedu/foodrem/logic/commands/itemcommands/FilterTagCommand.java
@@ -15,8 +15,7 @@
* Filters all items in FoodRem for items that contain the specified tag
*/
public class FilterTagCommand extends Command {
- private final TagSetContainsTagPredicate pred;
-
+ private final TagSetContainsTagPredicate predicate;
private final Tag tag;
/**
@@ -24,10 +23,13 @@ public class FilterTagCommand extends Command {
*/
public FilterTagCommand(Tag tag) {
requireNonNull(tag);
- this.pred = new TagSetContainsTagPredicate(tag);
+ this.predicate = new TagSetContainsTagPredicate(tag);
this.tag = tag;
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public CommandResult execute(Model model) throws CommandException {
requireNonNull(model);
@@ -36,20 +38,28 @@ public CommandResult execute(Model model) throws CommandException {
throw new CommandException("This tag does not exist in FoodRem");
}
- model.updateFilteredItemList(pred);
+ model.updateFilteredItemList(predicate);
String primaryMessage = "Filtered by tag:";
String secondaryMessage = String.format("%s items filtered", model.getCurrentList().size());
return CommandResult.from(new FilterByTag(tag, primaryMessage, secondaryMessage));
}
+ /**
+ * Returns a string representing how to use the command.
+ *
+ * @return a string representing how to use the command.
+ */
public static String getUsage() {
return FILTER_TAG_COMMAND.getUsage();
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public boolean equals(Object other) {
return other == this
|| (other instanceof FilterTagCommand
- && this.pred.equals(((FilterTagCommand) other).pred));
+ && this.predicate.equals(((FilterTagCommand) other).predicate));
}
}
diff --git a/src/main/java/seedu/foodrem/logic/commands/itemcommands/FindCommand.java b/src/main/java/seedu/foodrem/logic/commands/itemcommands/FindCommand.java
index 29392c3cab3..c1787166620 100644
--- a/src/main/java/seedu/foodrem/logic/commands/itemcommands/FindCommand.java
+++ b/src/main/java/seedu/foodrem/logic/commands/itemcommands/FindCommand.java
@@ -16,10 +16,16 @@
public class FindCommand extends Command {
private final NameContainsKeywordsPredicate predicate;
+ /**
+ * Constructs the FindCommand.
+ */
public FindCommand(NameContainsKeywordsPredicate predicate) {
this.predicate = predicate;
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public CommandResult execute(Model model) {
requireNonNull(model);
@@ -28,10 +34,18 @@ public CommandResult execute(Model model) {
String.format(Messages.MESSAGE_ITEMS_LISTED_OVERVIEW, model.getCurrentList().size()));
}
+ /**
+ * Returns a string representing how to use the command.
+ *
+ * @return a string representing how to use the command.
+ */
public static String getUsage() {
return FIND_COMMAND.getUsage();
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public boolean equals(Object other) {
return other == this
diff --git a/src/main/java/seedu/foodrem/logic/commands/itemcommands/IncrementCommand.java b/src/main/java/seedu/foodrem/logic/commands/itemcommands/IncrementCommand.java
index c93dd5a96e4..e1fd553514c 100644
--- a/src/main/java/seedu/foodrem/logic/commands/itemcommands/IncrementCommand.java
+++ b/src/main/java/seedu/foodrem/logic/commands/itemcommands/IncrementCommand.java
@@ -59,6 +59,9 @@ private static Item createIncrementedItem(Item itemToIncrement, ItemQuantity qua
itemToIncrement.getTagSet());
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public CommandResult execute(Model model) throws CommandException {
requireNonNull(model);
@@ -76,6 +79,18 @@ public CommandResult execute(Model model) throws CommandExcepti
"Incremented successfully and updated item as follows:"));
}
+ /**
+ * Returns a string representing how to use the command.
+ *
+ * @return a string representing how to use the command.
+ */
+ public static String getUsage() {
+ return INCREMENT_COMMAND.getUsage();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
@Override
public boolean equals(Object other) {
return other == this
@@ -83,8 +98,4 @@ public boolean equals(Object other) {
&& index.equals(((IncrementCommand) other).index)
&& quantity.equals(((IncrementCommand) other).quantity));
}
-
- public static String getUsage() {
- return INCREMENT_COMMAND.getUsage();
- }
}
diff --git a/src/main/java/seedu/foodrem/logic/commands/itemcommands/ListCommand.java b/src/main/java/seedu/foodrem/logic/commands/itemcommands/ListCommand.java
index a474886b22c..e4270a6ebf6 100644
--- a/src/main/java/seedu/foodrem/logic/commands/itemcommands/ListCommand.java
+++ b/src/main/java/seedu/foodrem/logic/commands/itemcommands/ListCommand.java
@@ -11,6 +11,9 @@
* Lists all items in FoodRem to the user.
*/
public class ListCommand extends Command {
+ /**
+ * {@inheritDoc}
+ */
@Override
public CommandResult execute(Model model) {
requireNonNull(model);
@@ -18,6 +21,11 @@ public CommandResult execute(Model model) {
return CommandResult.from("Listed all items");
}
+ /**
+ * Returns a string representing how to use the command.
+ *
+ * @return a string representing how to use the command.
+ */
public static String getUsage() {
return LIST_COMMAND.getUsage();
}
diff --git a/src/main/java/seedu/foodrem/logic/commands/itemcommands/NewCommand.java b/src/main/java/seedu/foodrem/logic/commands/itemcommands/NewCommand.java
index f60656d1065..21fdcaf4113 100644
--- a/src/main/java/seedu/foodrem/logic/commands/itemcommands/NewCommand.java
+++ b/src/main/java/seedu/foodrem/logic/commands/itemcommands/NewCommand.java
@@ -25,6 +25,9 @@ public NewCommand(Item item) {
newItem = item;
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public CommandResult execute(Model model) throws CommandException {
requireNonNull(model);
@@ -42,10 +45,18 @@ public CommandResult execute(Model model) throws CommandExcepti
return CommandResult.from(new ItemWithMessage(newItem, "New item added as follows:"));
}
+ /**
+ * Returns a string representing how to use the command.
+ *
+ * @return a string representing how to use the command.
+ */
public static String getUsage() {
return NEW_COMMAND.getUsage();
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public boolean equals(Object other) {
return other == this
diff --git a/src/main/java/seedu/foodrem/logic/commands/itemcommands/RemarkCommand.java b/src/main/java/seedu/foodrem/logic/commands/itemcommands/RemarkCommand.java
index 178185de9a5..434c329b805 100644
--- a/src/main/java/seedu/foodrem/logic/commands/itemcommands/RemarkCommand.java
+++ b/src/main/java/seedu/foodrem/logic/commands/itemcommands/RemarkCommand.java
@@ -23,6 +23,7 @@ public class RemarkCommand extends Command {
private final ItemRemark remark;
/**
+ * Constructs the RemarkCommand.
* @param index of the item in the filtered item list to increment.
* @param remark the remark to be added to the item.
*/
@@ -50,6 +51,9 @@ private static Item createItemWithRemark(Item itemToRemark, ItemRemark remark) {
itemToRemark.getTagSet());
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public CommandResult execute(Model model) throws CommandException {
requireNonNull(model);
@@ -67,10 +71,18 @@ public CommandResult execute(Model model) throws CommandExcepti
"Remark has been updated. View the updated item below:"));
}
+ /**
+ * Returns a string representing how to use the command.
+ *
+ * @return a string representing how to use the command.
+ */
public static String getUsage() {
return REMARK_COMMAND.getUsage();
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public boolean equals(Object other) {
return other == this
diff --git a/src/main/java/seedu/foodrem/logic/commands/itemcommands/SortCommand.java b/src/main/java/seedu/foodrem/logic/commands/itemcommands/SortCommand.java
index 7d622ffb8e3..a83b22fad97 100644
--- a/src/main/java/seedu/foodrem/logic/commands/itemcommands/SortCommand.java
+++ b/src/main/java/seedu/foodrem/logic/commands/itemcommands/SortCommand.java
@@ -26,10 +26,16 @@
public class SortCommand extends Command {
private final Comparator
- comparator;
+ /**
+ * Constructs the SortCommand.
+ */
public SortCommand(Comparator
- comparator) {
this.comparator = comparator;
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public CommandResult execute(Model model) {
requireNonNull(model);
@@ -38,10 +44,18 @@ public CommandResult execute(Model model) {
model.getCurrentList().size()));
}
+ /**
+ * Returns a string representing how to use the command.
+ *
+ * @return a string representing how to use the command.
+ */
public static String getUsage() {
return SORT_COMMAND.getUsage();
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public boolean equals(Object other) {
return other == this
diff --git a/src/main/java/seedu/foodrem/logic/commands/itemcommands/ViewCommand.java b/src/main/java/seedu/foodrem/logic/commands/itemcommands/ViewCommand.java
index b7556165a1f..ce9b1160617 100644
--- a/src/main/java/seedu/foodrem/logic/commands/itemcommands/ViewCommand.java
+++ b/src/main/java/seedu/foodrem/logic/commands/itemcommands/ViewCommand.java
@@ -30,6 +30,9 @@ public ViewCommand(Index index) {
this.index = index;
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public CommandResult
- execute(Model model) throws CommandException {
requireNonNull(model);
@@ -43,14 +46,22 @@ public CommandResult
- execute(Model model) throws CommandException {
return CommandResult.from(itemToDisplayInformation);
}
+ /**
+ * Returns a string representing how to use the command.
+ *
+ * @return a string representing how to use the command.
+ */
+ public static String getUsage() {
+ return VIEW_COMMAND.getUsage();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
@Override
public boolean equals(Object other) {
return other == this
|| (other instanceof ViewCommand
&& index.equals(((ViewCommand) other).index));
}
-
- public static String getUsage() {
- return VIEW_COMMAND.getUsage();
- }
}
diff --git a/src/main/java/seedu/foodrem/logic/commands/statscommands/StatsCommand.java b/src/main/java/seedu/foodrem/logic/commands/statscommands/StatsCommand.java
index b9200b67d4d..cfdf2d8eb85 100644
--- a/src/main/java/seedu/foodrem/logic/commands/statscommands/StatsCommand.java
+++ b/src/main/java/seedu/foodrem/logic/commands/statscommands/StatsCommand.java
@@ -33,6 +33,11 @@ public CommandResult execute(Model model) {
return CommandResult.from(new Stats(amountWasted, expensiveItems, commonTags));
}
+ /**
+ * Returns a string representing how to use the command.
+ *
+ * @return a string representing how to use the command.
+ */
public static String getUsage() {
return STATS_COMMAND.getUsage();
}
diff --git a/src/main/java/seedu/foodrem/logic/commands/tagcommands/DeleteTagCommand.java b/src/main/java/seedu/foodrem/logic/commands/tagcommands/DeleteTagCommand.java
index d1780413346..ae523f408ae 100644
--- a/src/main/java/seedu/foodrem/logic/commands/tagcommands/DeleteTagCommand.java
+++ b/src/main/java/seedu/foodrem/logic/commands/tagcommands/DeleteTagCommand.java
@@ -38,6 +38,11 @@ public CommandResult execute(Model model) throws CommandExcepti
return CommandResult.from(new TagsWithMessage("Tag deleted:", toDelete));
}
+ /**
+ * Returns a string representing how to use the command.
+ *
+ * @return a string representing how to use the command.
+ */
public static String getUsage() {
return DELETE_TAG_COMMAND.getUsage();
}
diff --git a/src/main/java/seedu/foodrem/logic/commands/tagcommands/NewTagCommand.java b/src/main/java/seedu/foodrem/logic/commands/tagcommands/NewTagCommand.java
index 4708c40d21c..3527137619f 100644
--- a/src/main/java/seedu/foodrem/logic/commands/tagcommands/NewTagCommand.java
+++ b/src/main/java/seedu/foodrem/logic/commands/tagcommands/NewTagCommand.java
@@ -44,6 +44,11 @@ public CommandResult execute(Model model) throws CommandExcepti
return CommandResult.from(new TagsWithMessage("New tag added:", toAdd));
}
+ /**
+ * Returns a string representing how to use the command.
+ *
+ * @return a string representing how to use the command.
+ */
public static String getUsage() {
return NEW_TAG_COMMAND.getUsage();
}
diff --git a/src/main/java/seedu/foodrem/logic/commands/tagcommands/RenameTagCommand.java b/src/main/java/seedu/foodrem/logic/commands/tagcommands/RenameTagCommand.java
index 6beba5f2c8e..9c26cb42867 100644
--- a/src/main/java/seedu/foodrem/logic/commands/tagcommands/RenameTagCommand.java
+++ b/src/main/java/seedu/foodrem/logic/commands/tagcommands/RenameTagCommand.java
@@ -46,6 +46,11 @@ public CommandResult execute(Model model) throws CommandException {
return CommandResult.from(new TagToRename(originalTag, renamedTag, "Tag renamed:"));
}
+ /**
+ * Returns a string representing how to use the command.
+ *
+ * @return a string representing how to use the command.
+ */
public static String getUsage() {
return RENAME_TAG_COMMAND.getUsage();
}
diff --git a/src/main/java/seedu/foodrem/logic/commands/tagcommands/TagCommand.java b/src/main/java/seedu/foodrem/logic/commands/tagcommands/TagCommand.java
index 6ba2e57ac83..bfc59d6054f 100644
--- a/src/main/java/seedu/foodrem/logic/commands/tagcommands/TagCommand.java
+++ b/src/main/java/seedu/foodrem/logic/commands/tagcommands/TagCommand.java
@@ -50,6 +50,11 @@ public CommandResult execute(Model model) throws CommandExcepti
return CommandResult.from(new ItemWithMessage(newTagSetItem, "Item tagged successfully. Updated item:"));
}
+ /**
+ * Returns a string representing how to use the command.
+ *
+ * @return a string representing how to use the command.
+ */
public static String getUsage() {
return TAG_COMMAND.getUsage();
}
diff --git a/src/main/java/seedu/foodrem/logic/commands/tagcommands/UntagCommand.java b/src/main/java/seedu/foodrem/logic/commands/tagcommands/UntagCommand.java
index fa070755c3c..cd3533c46fa 100644
--- a/src/main/java/seedu/foodrem/logic/commands/tagcommands/UntagCommand.java
+++ b/src/main/java/seedu/foodrem/logic/commands/tagcommands/UntagCommand.java
@@ -50,6 +50,11 @@ public CommandResult execute(Model model) throws CommandExcepti
return CommandResult.from(new ItemWithMessage(newTagSetItem, "Item untagged successfully. Updated item:"));
}
+ /**
+ * Returns a string representing how to use the command.
+ *
+ * @return a string representing how to use the command.
+ */
public static String getUsage() {
return UNTAG_COMMAND.getUsage();
}
From db193cddcd119a4a851ee2777b3fa3ba5eaf3104 Mon Sep 17 00:00:00 2001
From: Tan Yi Xian <>
Date: Sun, 6 Nov 2022 15:01:21 +0800
Subject: [PATCH 08/25] Add javadoc to comparators
---
.../itemcommandparser/EditCommandParser.java | 64 +++++++++++++++++--
.../itemcomparators/ItemPriceComparator.java | 9 +++
.../itemcomparators/ItemRemarkComparator.java | 9 +++
.../itemcomparators/ItemValueComparator.java | 6 ++
4 files changed, 82 insertions(+), 6 deletions(-)
diff --git a/src/main/java/seedu/foodrem/logic/parser/itemcommandparser/EditCommandParser.java b/src/main/java/seedu/foodrem/logic/parser/itemcommandparser/EditCommandParser.java
index f29772cb7c1..ef41afa5914 100644
--- a/src/main/java/seedu/foodrem/logic/parser/itemcommandparser/EditCommandParser.java
+++ b/src/main/java/seedu/foodrem/logic/parser/itemcommandparser/EditCommandParser.java
@@ -17,6 +17,9 @@
* Parses input arguments and creates a new EditCommand object
*/
public class EditCommandParser implements Parser {
+
+ private static final String MESSAGE_NOT_EDITED = "At least one field to edit must be provided.";
+
/**
* Parses the given {@code String} of arguments in the context of the EditCommand
* and returns an EditCommand object for execution.
@@ -38,39 +41,88 @@ public EditCommand parse(String args) throws ParseException {
EditCommand.getUsage());
EditItemDescriptor editItemDescriptor = new EditItemDescriptor();
+ setItemNameIfValuePresent(editItemDescriptor, argMultimap);
+ setItemQuantityIfValuePresent(editItemDescriptor, argMultimap);
+ setItemUnitIfValuePresent(editItemDescriptor, argMultimap);
+ setItemBoughtDateIfValuePresent(editItemDescriptor, argMultimap);
+ setItemExpiryDateIfValuePresent(editItemDescriptor, argMultimap);
+ setItemPriceIfValuePresent(editItemDescriptor, argMultimap);
+ setItemRemarkIfValuePresent(editItemDescriptor, argMultimap);
+
+ if (!editItemDescriptor.isAnyFieldEdited()) {
+ throw new ParseException(MESSAGE_NOT_EDITED);
+ }
+
+ return new EditCommand(index, editItemDescriptor);
+ }
+
+ /**
+ * Sets ItemName of the editItemDescriptor if the value is present in the ArgumentMultimap.
+ */
+ private void setItemNameIfValuePresent(EditItemDescriptor editItemDescriptor, ArgumentMultimap argMultimap) {
if (argMultimap.isValuePresent(CliSyntax.PREFIX_NAME)) {
editItemDescriptor.setItemName(
ParserUtil.parseItemName(argMultimap.getPresentValue(CliSyntax.PREFIX_NAME)));
}
+ }
+
+ /**
+ * Sets ItemQuantity of the editItemDescriptor if the value is present in the ArgumentMultimap.
+ */
+ private void setItemQuantityIfValuePresent(EditItemDescriptor editItemDescriptor, ArgumentMultimap argMultimap) {
if (argMultimap.isValuePresent(CliSyntax.PREFIX_ITEM_QUANTITY)) {
editItemDescriptor.setItemQuantity(
ParserUtil.parseQuantity(argMultimap.getPresentValue(CliSyntax.PREFIX_ITEM_QUANTITY)));
}
+ }
+
+ /**
+ * Sets ItemUnit of the editItemDescriptor if the value is present in the ArgumentMultimap.
+ */
+ private void setItemUnitIfValuePresent(EditItemDescriptor editItemDescriptor, ArgumentMultimap argMultimap) {
if (argMultimap.isValuePresent(CliSyntax.PREFIX_ITEM_UNIT)) {
editItemDescriptor.setItemUnit(
ParserUtil.parseUnit(argMultimap.getPresentValue(CliSyntax.PREFIX_ITEM_UNIT)));
}
+ }
+
+ /**
+ * Sets ItemBoughtDate of the editItemDescriptor if the value is present in the ArgumentMultimap.
+ */
+ private void setItemBoughtDateIfValuePresent(EditItemDescriptor editItemDescriptor, ArgumentMultimap argMultimap) {
if (argMultimap.isValuePresent(CliSyntax.PREFIX_ITEM_BOUGHT_DATE)) {
editItemDescriptor.setItemBoughtDate(
ParserUtil.parseBoughtDate(argMultimap.getPresentValue(CliSyntax.PREFIX_ITEM_BOUGHT_DATE)));
}
+ }
+
+ /**
+ * Sets ItemExpiryDate of the editItemDescriptor if the value is present in the ArgumentMultimap.
+ */
+ private void setItemExpiryDateIfValuePresent(EditItemDescriptor editItemDescriptor, ArgumentMultimap argMultimap) {
if (argMultimap.isValuePresent(CliSyntax.PREFIX_ITEM_EXPIRY_DATE)) {
editItemDescriptor.setItemExpiryDate(
ParserUtil.parseExpiryDate(argMultimap.getPresentValue(CliSyntax.PREFIX_ITEM_EXPIRY_DATE)));
}
+ }
+
+ /**
+ * Sets ItemPrice of the editItemDescriptor if the value is present in the ArgumentMultimap.
+ */
+ private void setItemPriceIfValuePresent(EditItemDescriptor editItemDescriptor, ArgumentMultimap argMultimap) {
if (argMultimap.isValuePresent(CliSyntax.PREFIX_ITEM_PRICE)) {
editItemDescriptor.setItemPrice(
ParserUtil.parsePrice(argMultimap.getPresentValue(CliSyntax.PREFIX_ITEM_PRICE)));
}
+ }
+
+ /**
+ * Sets ItemRemarks of the editItemDescriptor if the value is present in the ArgumentMultimap.
+ */
+ private void setItemRemarkIfValuePresent(EditItemDescriptor editItemDescriptor, ArgumentMultimap argMultimap) {
if (argMultimap.isValuePresent(CliSyntax.PREFIX_ITEM_REMARKS)) {
editItemDescriptor.setItemRemarks(
ParserUtil.parseRemarks(argMultimap.getPresentValue(CliSyntax.PREFIX_ITEM_REMARKS)));
}
-
- if (!editItemDescriptor.isAnyFieldEdited()) {
- throw new ParseException(EditCommand.MESSAGE_NOT_EDITED);
- }
-
- return new EditCommand(index, editItemDescriptor);
}
}
diff --git a/src/main/java/seedu/foodrem/model/item/itemcomparators/ItemPriceComparator.java b/src/main/java/seedu/foodrem/model/item/itemcomparators/ItemPriceComparator.java
index 7f510299e7d..5ef70dff2ca 100644
--- a/src/main/java/seedu/foodrem/model/item/itemcomparators/ItemPriceComparator.java
+++ b/src/main/java/seedu/foodrem/model/item/itemcomparators/ItemPriceComparator.java
@@ -6,11 +6,20 @@
* Comparator comparing between ItemPrices
*/
public class ItemPriceComparator implements ItemComparator {
+ /**
+ * Compares two items by price.
+ * @param item1 the first item to compare.
+ * @param item2 the second item to compare.
+ * @return an integer representing the order of the items.
+ */
@Override
public int compare(Item item1, Item item2) {
return item1.getPrice().compareTo(item2.getPrice());
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public boolean equals(Object other) {
return other == this;
diff --git a/src/main/java/seedu/foodrem/model/item/itemcomparators/ItemRemarkComparator.java b/src/main/java/seedu/foodrem/model/item/itemcomparators/ItemRemarkComparator.java
index 5046c61becf..0dca79b73bd 100644
--- a/src/main/java/seedu/foodrem/model/item/itemcomparators/ItemRemarkComparator.java
+++ b/src/main/java/seedu/foodrem/model/item/itemcomparators/ItemRemarkComparator.java
@@ -6,11 +6,20 @@
* Comparator comparing between ItemRemarks in lexicographical order.
*/
public class ItemRemarkComparator implements ItemComparator {
+ /**
+ * Compares two items by remark.
+ * @param item1 the first item to compare.
+ * @param item2 the second item to compare.
+ * @return an integer representing the order of the items.
+ */
@Override
public int compare(Item item1, Item item2) {
return item1.getRemarks().compareTo(item2.getRemarks());
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public boolean equals(Object other) {
return other == this;
diff --git a/src/main/java/seedu/foodrem/model/item/itemcomparators/ItemValueComparator.java b/src/main/java/seedu/foodrem/model/item/itemcomparators/ItemValueComparator.java
index aae670b73e1..3cd9a73571c 100644
--- a/src/main/java/seedu/foodrem/model/item/itemcomparators/ItemValueComparator.java
+++ b/src/main/java/seedu/foodrem/model/item/itemcomparators/ItemValueComparator.java
@@ -6,6 +6,12 @@
* Comparator comparing between ItemValues
*/
public class ItemValueComparator implements ItemComparator {
+ /**
+ * Compares two items by value.
+ * @param item1 the first item to compare.
+ * @param item2 the second item to compare.
+ * @return an integer representing the order of the items.
+ */
@Override
public int compare(Item item1, Item item2) {
return Double.compare(item1.getItemValue(), item2.getItemValue());
From ded4350f8550ca8099c1cbb35381dbd5fb8915d5 Mon Sep 17 00:00:00 2001
From: Tan Yi Xian <>
Date: Sun, 6 Nov 2022 15:01:39 +0800
Subject: [PATCH 09/25] Add javadoc to ListTagCommand
---
.../foodrem/logic/commands/tagcommands/ListTagCommand.java | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/main/java/seedu/foodrem/logic/commands/tagcommands/ListTagCommand.java b/src/main/java/seedu/foodrem/logic/commands/tagcommands/ListTagCommand.java
index 2baa997da14..0f9e2abb14c 100644
--- a/src/main/java/seedu/foodrem/logic/commands/tagcommands/ListTagCommand.java
+++ b/src/main/java/seedu/foodrem/logic/commands/tagcommands/ListTagCommand.java
@@ -22,6 +22,11 @@ public CommandResult execute(Model model) {
return CommandResult.from(new TagsWithMessage(MESSAGE_SUCCESS, model.getFilteredTagList().toArray(Tag[]::new)));
}
+ /**
+ * Returns a string representing how to use the command.
+ *
+ * @return a string representing how to use the command.
+ */
public static String getUsage() {
return LIST_TAG_COMMAND.getUsage();
}
From d0210bd33e9c453bab2ce86a00970d2913820b5c Mon Sep 17 00:00:00 2001
From: Tan Yi Xian <>
Date: Sun, 6 Nov 2022 15:01:54 +0800
Subject: [PATCH 10/25] Remove unused interface
---
src/main/java/seedu/foodrem/model/Model.java | 10 ----------
1 file changed, 10 deletions(-)
diff --git a/src/main/java/seedu/foodrem/model/Model.java b/src/main/java/seedu/foodrem/model/Model.java
index aab0fcc7081..b75ccc68e03 100644
--- a/src/main/java/seedu/foodrem/model/Model.java
+++ b/src/main/java/seedu/foodrem/model/Model.java
@@ -141,14 +141,4 @@ public interface Model {
* @throws NullPointerException if {@code comparator} is null.
*/
void updateSortedItemList(Comparator
- comparator);
-
- /**
- * Returns true if the item storage is full, false otherwise.
- */
- boolean isItemStorageFull();
-
- /**
- * Returns true if the tag storage is full, false otherwise.
- */
- boolean isTagStorageFull();
}
From bc368e3fa040346f09d4af48286ce67ab04aa38d Mon Sep 17 00:00:00 2001
From: Tan Yi Xian <>
Date: Sun, 6 Nov 2022 15:02:17 +0800
Subject: [PATCH 11/25] Add javadocs to interfaces
---
src/main/java/seedu/foodrem/model/ReadOnlyFoodRem.java | 4 ++++
src/main/java/seedu/foodrem/model/ReadOnlyUserPrefs.java | 6 ++++++
.../seedu/foodrem/model/item/itemvalidators/Validator.java | 3 +++
3 files changed, 13 insertions(+)
diff --git a/src/main/java/seedu/foodrem/model/ReadOnlyFoodRem.java b/src/main/java/seedu/foodrem/model/ReadOnlyFoodRem.java
index 5b12c457ce1..5f8d272c5af 100644
--- a/src/main/java/seedu/foodrem/model/ReadOnlyFoodRem.java
+++ b/src/main/java/seedu/foodrem/model/ReadOnlyFoodRem.java
@@ -14,5 +14,9 @@ public interface ReadOnlyFoodRem {
*/
ObservableList
- getItemList();
+ /**
+ * Returns an unmodifiable view of the tag list.
+ * This list will not contain any duplicate tags.
+ */
ObservableList getTagList();
}
diff --git a/src/main/java/seedu/foodrem/model/ReadOnlyUserPrefs.java b/src/main/java/seedu/foodrem/model/ReadOnlyUserPrefs.java
index e34073b5bf3..04930e496ed 100644
--- a/src/main/java/seedu/foodrem/model/ReadOnlyUserPrefs.java
+++ b/src/main/java/seedu/foodrem/model/ReadOnlyUserPrefs.java
@@ -8,7 +8,13 @@
* Unmodifiable view of user prefs.
*/
public interface ReadOnlyUserPrefs {
+ /**
+ * Returns the gui settings of FoodRem.
+ */
GuiSettings getGuiSettings();
+ /**
+ * Returns the Path of FoodRem.
+ */
Path getFoodRemFilePath();
}
diff --git a/src/main/java/seedu/foodrem/model/item/itemvalidators/Validator.java b/src/main/java/seedu/foodrem/model/item/itemvalidators/Validator.java
index 3d01e9465df..830e6b7e03d 100644
--- a/src/main/java/seedu/foodrem/model/item/itemvalidators/Validator.java
+++ b/src/main/java/seedu/foodrem/model/item/itemvalidators/Validator.java
@@ -4,6 +4,9 @@
* Interface for validation classes
*/
public interface Validator {
+ /**
+ * Validates if a string is valid.
+ */
static void validate(String string) {
}
}
From 0a65e639a555e2edd6bcdcf24195387f4eef0d8f Mon Sep 17 00:00:00 2001
From: Tan Yi Xian <>
Date: Sun, 6 Nov 2022 15:03:03 +0800
Subject: [PATCH 12/25] Add javadocs to ui related classes
---
src/main/java/seedu/foodrem/ui/HelpWindow.java | 3 +++
src/main/java/seedu/foodrem/viewmodels/FilterByTag.java | 9 +++++++++
.../java/seedu/foodrem/viewmodels/TagsWithMessage.java | 6 ++++++
3 files changed, 18 insertions(+)
diff --git a/src/main/java/seedu/foodrem/ui/HelpWindow.java b/src/main/java/seedu/foodrem/ui/HelpWindow.java
index 722b6fb8ef7..0b1265bc783 100644
--- a/src/main/java/seedu/foodrem/ui/HelpWindow.java
+++ b/src/main/java/seedu/foodrem/ui/HelpWindow.java
@@ -36,6 +36,9 @@ public HelpWindow() {
this(new Stage());
}
+ /**
+ * Sets the message to display.
+ */
public void setMessageToDisplay(String messageToDisplay) {
helpMessage.setText(messageToDisplay);
}
diff --git a/src/main/java/seedu/foodrem/viewmodels/FilterByTag.java b/src/main/java/seedu/foodrem/viewmodels/FilterByTag.java
index 2ab5d880068..9232f0091d1 100644
--- a/src/main/java/seedu/foodrem/viewmodels/FilterByTag.java
+++ b/src/main/java/seedu/foodrem/viewmodels/FilterByTag.java
@@ -25,14 +25,23 @@ public FilterByTag(Tag tag, String primaryMessage, String secondaryMessage) {
this.secondaryMessage = secondaryMessage;
}
+ /**
+ * Returns the tag.
+ */
public Tag getTag() {
return tag;
}
+ /**
+ * Returns the primary message.
+ */
public String getPrimaryMessage() {
return primaryMessage;
}
+ /**
+ * Returns the secondary message.
+ */
public String getSecondaryMessage() {
return secondaryMessage;
}
diff --git a/src/main/java/seedu/foodrem/viewmodels/TagsWithMessage.java b/src/main/java/seedu/foodrem/viewmodels/TagsWithMessage.java
index 0561c9e0e45..40932065381 100644
--- a/src/main/java/seedu/foodrem/viewmodels/TagsWithMessage.java
+++ b/src/main/java/seedu/foodrem/viewmodels/TagsWithMessage.java
@@ -23,10 +23,16 @@ public TagsWithMessage(String message, Tag... tags) {
this.message = message;
}
+ /**
+ * Returns the tags.
+ */
public Tag[] getTags() {
return tags;
}
+ /**
+ * Returns the message.
+ */
public String getMessage() {
return message;
}
From 81c8db7aecace05c9af7497f62264a0ed16db13a Mon Sep 17 00:00:00 2001
From: Tan Yi Xian <>
Date: Sun, 6 Nov 2022 15:03:18 +0800
Subject: [PATCH 13/25] Add javadoc to FindCommandParserTest
---
.../logic/parser/itemcommandparser/FindCommandParserTest.java | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/test/java/seedu/foodrem/logic/parser/itemcommandparser/FindCommandParserTest.java b/src/test/java/seedu/foodrem/logic/parser/itemcommandparser/FindCommandParserTest.java
index 2c5354381e1..16fb1f72af7 100644
--- a/src/test/java/seedu/foodrem/logic/parser/itemcommandparser/FindCommandParserTest.java
+++ b/src/test/java/seedu/foodrem/logic/parser/itemcommandparser/FindCommandParserTest.java
@@ -11,6 +11,9 @@
import seedu.foodrem.logic.commands.itemcommands.FindCommand;
import seedu.foodrem.model.item.NameContainsKeywordsPredicate;
+/**
+ * A class to test the FindCommandParser.
+ */
public class FindCommandParserTest {
private final FindCommandParser parser = new FindCommandParser();
From 59a1be835eeac15683638477bea35f6e31893fa3 Mon Sep 17 00:00:00 2001
From: Tan Yi Xian <>
Date: Sun, 6 Nov 2022 15:03:40 +0800
Subject: [PATCH 14/25] Add javadoc to TagToRename
---
src/main/java/seedu/foodrem/viewmodels/TagToRename.java | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/src/main/java/seedu/foodrem/viewmodels/TagToRename.java b/src/main/java/seedu/foodrem/viewmodels/TagToRename.java
index 97d4bde7fb3..6e97870d0bd 100644
--- a/src/main/java/seedu/foodrem/viewmodels/TagToRename.java
+++ b/src/main/java/seedu/foodrem/viewmodels/TagToRename.java
@@ -25,14 +25,23 @@ public TagToRename(Tag originalTag, Tag renamedTag, String message) {
this.message = message;
}
+ /**
+ * Returns the original tag.
+ */
public Tag getOriginalTag() {
return originalTag;
}
+ /**
+ * Returns the renamed tag.
+ */
public Tag getRenamedTag() {
return renamedTag;
}
+ /**
+ * Returns the message.
+ */
public String getMessage() {
return message;
}
From a0fc10ce956c2db02e6a44d448e1bc2ad08302c2 Mon Sep 17 00:00:00 2001
From: Tan Yi Xian <>
Date: Sun, 6 Nov 2022 15:06:41 +0800
Subject: [PATCH 15/25] Apply SLAP to JsonAdaptedItem
---
.../foodrem/storage/JsonAdaptedItem.java | 52 ++++++++-----------
1 file changed, 23 insertions(+), 29 deletions(-)
diff --git a/src/main/java/seedu/foodrem/storage/JsonAdaptedItem.java b/src/main/java/seedu/foodrem/storage/JsonAdaptedItem.java
index 0c006b2b99c..d6f18203453 100644
--- a/src/main/java/seedu/foodrem/storage/JsonAdaptedItem.java
+++ b/src/main/java/seedu/foodrem/storage/JsonAdaptedItem.java
@@ -24,7 +24,7 @@
* Jackson-friendly version of {@link Item}.
*/
class JsonAdaptedItem {
- public static final String MISSING_FIELD_MESSAGE_FORMAT = "Item's %s field is missing!";
+ private static final String MISSING_FIELD_MESSAGE_FORMAT = "Item's %s field is missing!";
private final String name;
private final String quantity;
@@ -77,61 +77,55 @@ public JsonAdaptedItem(Item source) {
* @throws IllegalArgumentException if there were any data constraints violated in the adapted item.
*/
public Item toModelType() throws IllegalArgumentException {
+ checkIfFieldsAreNull();
+
+ final Set modelTags = new HashSet<>();
+ modelTags.addAll(tags.stream().map(JsonAdaptedTag::toModelType).collect(Collectors.toList()));
+
+ return new Item(
+ new ItemName(name),
+ new ItemQuantity(quantity),
+ new ItemUnit(unit),
+ ItemBoughtDate.of(boughtDate),
+ ItemExpiryDate.of(expiryDate),
+ new ItemPrice(price),
+ new ItemRemark(remarks),
+ modelTags);
+ }
+
+ /**
+ * Checks if the fields in the JsonAdaptedItem are null.
+ *
+ * @throws IllegalArgumentException if there were any data constraints violated in the adapted item.
+ */
+ private void checkIfFieldsAreNull() {
if (name == null) {
throw new IllegalArgumentException(String.format(MISSING_FIELD_MESSAGE_FORMAT,
ItemName.class.getSimpleName()));
}
- final ItemName modelItemName = new ItemName(name);
-
if (quantity == null) {
throw new IllegalArgumentException(String.format(MISSING_FIELD_MESSAGE_FORMAT,
ItemQuantity.class.getSimpleName()));
}
- final ItemQuantity modelItemQuantity = new ItemQuantity(quantity);
-
if (unit == null) {
throw new IllegalArgumentException(String.format(MISSING_FIELD_MESSAGE_FORMAT,
ItemUnit.class.getSimpleName()));
}
- final ItemUnit modelItemUnit = new ItemUnit(unit);
-
if (boughtDate == null) {
throw new IllegalArgumentException(String.format(MISSING_FIELD_MESSAGE_FORMAT,
ItemBoughtDate.class.getSimpleName()));
}
- final ItemBoughtDate modelItemBoughtDate = ItemBoughtDate.of(boughtDate);
-
if (expiryDate == null) {
throw new IllegalArgumentException(String.format(MISSING_FIELD_MESSAGE_FORMAT,
ItemExpiryDate.class.getSimpleName()));
}
- final ItemExpiryDate modelItemExpiryDate = ItemExpiryDate.of(expiryDate);
-
if (price == null) {
throw new IllegalArgumentException(String.format(MISSING_FIELD_MESSAGE_FORMAT,
ItemPrice.class.getSimpleName()));
}
- final ItemPrice modelItemPrice = new ItemPrice(price);
-
if (remarks == null) {
throw new IllegalArgumentException(String.format(MISSING_FIELD_MESSAGE_FORMAT,
ItemRemark.class.getSimpleName()));
}
- final ItemRemark modelItemRemark = new ItemRemark(remarks);
-
- final List itemTags = new ArrayList<>();
- for (JsonAdaptedTag tag : tags) {
- itemTags.add(tag.toModelType());
- }
-
- final Set modelTags = new HashSet<>(itemTags);
- return new Item(modelItemName,
- modelItemQuantity,
- modelItemUnit,
- modelItemBoughtDate,
- modelItemExpiryDate,
- modelItemPrice,
- modelItemRemark,
- modelTags);
}
}
From 88fef07b4d3c163c78eba80cd6780108ec17532d Mon Sep 17 00:00:00 2001
From: Tan Yi Xian <>
Date: Sun, 6 Nov 2022 15:06:57 +0800
Subject: [PATCH 16/25] Add javadoc to ItemWithMessage
---
src/main/java/seedu/foodrem/viewmodels/ItemWithMessage.java | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/src/main/java/seedu/foodrem/viewmodels/ItemWithMessage.java b/src/main/java/seedu/foodrem/viewmodels/ItemWithMessage.java
index b1b20297316..ed9c767cedd 100644
--- a/src/main/java/seedu/foodrem/viewmodels/ItemWithMessage.java
+++ b/src/main/java/seedu/foodrem/viewmodels/ItemWithMessage.java
@@ -22,10 +22,16 @@ public ItemWithMessage(Item item, String message) {
this.message = message;
}
+ /**
+ * Returns the item.
+ */
public Item getItem() {
return item;
}
+ /**
+ * Returns the message.
+ */
public String getMessage() {
return message;
}
From d9f77f7facef11eeb7b5f6ac3974d12d851445ae Mon Sep 17 00:00:00 2001
From: Tan Yi Xian <>
Date: Sun, 6 Nov 2022 15:09:39 +0800
Subject: [PATCH 17/25] Add javadoc to storage, lists, logic, model and ui
---
.../foodrem/commons/core/index/Index.java | 6 ++++
.../seedu/foodrem/logic/LogicManager.java | 18 +++++++++++
.../java/seedu/foodrem/model/FoodRem.java | 5 ++++
.../seedu/foodrem/model/ModelManager.java | 13 ++------
.../foodrem/model/item/UniqueItemList.java | 30 ++++++++++++++++++-
.../foodrem/model/tag/UniqueTagList.java | 3 ++
.../foodrem/storage/JsonFoodRemStorage.java | 12 ++++++++
.../seedu/foodrem/storage/StorageManager.java | 24 +++++++++++++++
src/main/java/seedu/foodrem/ui/UiManager.java | 3 ++
.../foodrem/testutil/FoodRemBuilder.java | 9 ++++++
10 files changed, 112 insertions(+), 11 deletions(-)
diff --git a/src/main/java/seedu/foodrem/commons/core/index/Index.java b/src/main/java/seedu/foodrem/commons/core/index/Index.java
index 686da97bf7b..08781bd1f3e 100644
--- a/src/main/java/seedu/foodrem/commons/core/index/Index.java
+++ b/src/main/java/seedu/foodrem/commons/core/index/Index.java
@@ -37,10 +37,16 @@ public static Index fromOneBased(int oneBasedIndex) {
return new Index(oneBasedIndex - 1);
}
+ /**
+ * Returns the zeroBasedIndex.
+ */
public int getZeroBased() {
return zeroBasedIndex;
}
+ /**
+ * Returns the oneBasedIndex.
+ */
public int getOneBased() {
return zeroBasedIndex + 1;
}
diff --git a/src/main/java/seedu/foodrem/logic/LogicManager.java b/src/main/java/seedu/foodrem/logic/LogicManager.java
index 29fe4bdc1ae..bf79701e452 100644
--- a/src/main/java/seedu/foodrem/logic/LogicManager.java
+++ b/src/main/java/seedu/foodrem/logic/LogicManager.java
@@ -37,6 +37,9 @@ public LogicManager(Model model, Storage storage) {
foodRemParser = new FoodRemParser();
}
+ /**
+ * @inheritDoc
+ */
@Override
public CommandResult> execute(String commandText) throws CommandException, ParseException {
logger.info("----------------[USER COMMAND][" + commandText + "]");
@@ -54,26 +57,41 @@ public CommandResult> execute(String commandText) throws CommandException, Par
return commandResult;
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public ReadOnlyFoodRem getFoodRem() {
return model.getFoodRem();
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public ObservableList
- getCurrentList() {
return model.getCurrentList();
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public Path getFoodRemFilePath() {
return model.getFoodRemFilePath();
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public GuiSettings getGuiSettings() {
return model.getGuiSettings();
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void setGuiSettings(GuiSettings guiSettings) {
model.setGuiSettings(guiSettings);
diff --git a/src/main/java/seedu/foodrem/model/FoodRem.java b/src/main/java/seedu/foodrem/model/FoodRem.java
index 6f5f1704089..9c1e739e28e 100644
--- a/src/main/java/seedu/foodrem/model/FoodRem.java
+++ b/src/main/java/seedu/foodrem/model/FoodRem.java
@@ -32,10 +32,15 @@ public class FoodRem implements ReadOnlyFoodRem {
tags = new UniqueTagList();
}
+ /**
+ * Constructs a FoodRem.
+ */
public FoodRem() {}
/**
* Creates a FoodRem using the Items in the {@code toBeCopied}
+ *
+ * @param toBeCopied the ReadOnlyFoodRem.
*/
public FoodRem(ReadOnlyFoodRem toBeCopied) {
this();
diff --git a/src/main/java/seedu/foodrem/model/ModelManager.java b/src/main/java/seedu/foodrem/model/ModelManager.java
index 6cff36475f1..0967293d4b2 100644
--- a/src/main/java/seedu/foodrem/model/ModelManager.java
+++ b/src/main/java/seedu/foodrem/model/ModelManager.java
@@ -46,6 +46,9 @@ public ModelManager(ReadOnlyFoodRem foodRem, ReadOnlyUserPrefs userPrefs) {
filteredTags = new FilteredList<>(this.foodRem.getTagList());
}
+ /**
+ * Initializes a ModelManager with an empty foodRem and defajult userPrefs.
+ */
public ModelManager() {
this(new FoodRem(), new UserPrefs());
}
@@ -85,16 +88,6 @@ public void setFoodRemFilePath(Path foodRemFilePath) {
userPrefs.setFoodRemFilePath(foodRemFilePath);
}
- @Override
- public boolean isItemStorageFull() {
- return foodRem.isItemStorageFull();
- }
-
- @Override
- public boolean isTagStorageFull() {
- return foodRem.isTagStorageFull();
- }
-
//=========== FoodRem ================================================================================
@Override
diff --git a/src/main/java/seedu/foodrem/model/item/UniqueItemList.java b/src/main/java/seedu/foodrem/model/item/UniqueItemList.java
index de07b421656..a9e904a58a1 100644
--- a/src/main/java/seedu/foodrem/model/item/UniqueItemList.java
+++ b/src/main/java/seedu/foodrem/model/item/UniqueItemList.java
@@ -31,6 +31,8 @@ public class UniqueItemList implements Iterable
- {
/**
* Returns {@code true} if the list contains an equivalent item as the given argument.
+ *
+ * @return true if the item list contains the item, false otherwise.
*/
public boolean contains(Item toCheck) {
requireNonNull(toCheck);
@@ -39,6 +41,8 @@ public boolean contains(Item toCheck) {
/**
* Returns true is the storage is full, false otherwise.
+ *
+ * @return true if the storage is full, false otherwise.
*/
public boolean isStorageFull() {
return internalList.size() == MAX_ITEMS;
@@ -47,6 +51,8 @@ public boolean isStorageFull() {
/**
* Adds an item to the list.
* The item must not already exist in the list.
+ *
+ * @param toAdd the item to add.
*/
public void add(Item toAdd) {
requireNonNull(toAdd);
@@ -63,6 +69,9 @@ public void add(Item toAdd) {
* Replaces the item {@code target} in the list with {@code editedItem}.
* {@code target} must exist in the list.
* The item identity of {@code editedItem} must not be the same as another existing item in the list.
+ *
+ * @param target the item to be removed from the list.
+ * @param editedItem the item to be added to the list.
*/
public void setItem(Item target, Item editedItem) {
requireAllNonNull(target, editedItem);
@@ -82,6 +91,8 @@ public void setItem(Item target, Item editedItem) {
/**
* Removes the equivalent item from the list.
* The item must exist in the list.
+ *
+ * @param toRemove the item to be removed from the list.
*/
public void remove(Item toRemove) {
requireNonNull(toRemove);
@@ -90,6 +101,11 @@ public void remove(Item toRemove) {
}
}
+ /**
+ * Replaces all the items in the list.
+ *
+ * @param replacement the new item list.
+ */
public void setItems(UniqueItemList replacement) {
requireNonNull(replacement);
internalList.setAll(replacement.internalList);
@@ -98,13 +114,14 @@ public void setItems(UniqueItemList replacement) {
/**
* Replaces the contents of this list with {@code items}.
* {@code items} must not contain duplicate items.
+ *
+ * @param items the new item list.
*/
public void setItems(List
- items) {
requireAllNonNull(items);
if (!itemsAreUnique(items)) {
throw new DuplicateItemException();
}
-
internalList.setAll(items);
}
@@ -115,11 +132,17 @@ public ObservableList
- asUnmodifiableObservableList() {
return internalUnmodifiableList;
}
+ /**
+ * Returns the iterator of the internalList.
+ */
@Override
public Iterator
- iterator() {
return internalList.iterator();
}
+ /**
+ * Returns {@code true} if both {@link UniqueItemList} have the same items.
+ */
@Override
public boolean equals(Object other) {
return other == this
@@ -127,6 +150,9 @@ public boolean equals(Object other) {
&& internalList.equals(((UniqueItemList) other).internalList));
}
+ /**
+ * Returns the hashCode of the unique item list.
+ */
@Override
public int hashCode() {
return internalList.hashCode();
@@ -134,6 +160,8 @@ public int hashCode() {
/**
* Returns {@code true} if {@code items} contains only unique items.
+ *
+ * @return true if the items contain only unique items, false otherwise.
*/
private boolean itemsAreUnique(List
- items) {
for (int i = 0; i < items.size() - 1; i++) {
diff --git a/src/main/java/seedu/foodrem/model/tag/UniqueTagList.java b/src/main/java/seedu/foodrem/model/tag/UniqueTagList.java
index 0313ee0940e..68bed3193c1 100644
--- a/src/main/java/seedu/foodrem/model/tag/UniqueTagList.java
+++ b/src/main/java/seedu/foodrem/model/tag/UniqueTagList.java
@@ -88,6 +88,9 @@ public void remove(Tag toRemove) {
}
}
+ /**
+ * Replaces the contents of this list with {@code tags}.
+ */
public void setTags(UniqueTagList replacement) {
requireNonNull(replacement);
internalList.setAll(replacement.internalList);
diff --git a/src/main/java/seedu/foodrem/storage/JsonFoodRemStorage.java b/src/main/java/seedu/foodrem/storage/JsonFoodRemStorage.java
index fc526d11af1..dcb6a996919 100644
--- a/src/main/java/seedu/foodrem/storage/JsonFoodRemStorage.java
+++ b/src/main/java/seedu/foodrem/storage/JsonFoodRemStorage.java
@@ -24,14 +24,23 @@ public class JsonFoodRemStorage implements FoodRemStorage {
private final Path filePath;
+ /**
+ * Constructs a JsonFoodRemStorage.
+ */
public JsonFoodRemStorage(Path filePath) {
this.filePath = filePath;
}
+ /**
+ * Returns a path to the file of the JsonFoodRemStorage.
+ */
public Path getFoodRemFilePath() {
return filePath;
}
+ /**
+ * Returns an optional ReadOnlyFoodRem.
+ */
@Override
public Optional readFoodRem() throws DataConversionException {
return readFoodRem(filePath);
@@ -66,6 +75,9 @@ public Optional readFoodRem(Path filePath) throws DataConversio
}
}
+ /**
+ * Saves a ReadOnlyFoodRem into the storage.
+ */
@Override
public void saveFoodRem(ReadOnlyFoodRem foodRem) throws IOException {
saveFoodRem(foodRem, filePath);
diff --git a/src/main/java/seedu/foodrem/storage/StorageManager.java b/src/main/java/seedu/foodrem/storage/StorageManager.java
index 61cd420bb4b..4b30521b507 100644
--- a/src/main/java/seedu/foodrem/storage/StorageManager.java
+++ b/src/main/java/seedu/foodrem/storage/StorageManager.java
@@ -30,16 +30,25 @@ public StorageManager(FoodRemStorage foodRemStorage, UserPrefsStorage userPrefsS
// ================ UserPrefs methods ==============================
+ /**
+ * {@inheritDoc}
+ */
@Override
public Path getUserPrefsFilePath() {
return userPrefsStorage.getUserPrefsFilePath();
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public Optional readUserPrefs() throws DataConversionException, IOException {
return userPrefsStorage.readUserPrefs();
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void saveUserPrefs(ReadOnlyUserPrefs userPrefs) throws IOException {
userPrefsStorage.saveUserPrefs(userPrefs);
@@ -47,27 +56,42 @@ public void saveUserPrefs(ReadOnlyUserPrefs userPrefs) throws IOException {
// ================ FoodRem methods ==============================
+ /**
+ * {@inheritDoc}
+ */
@Override
public Path getFoodRemFilePath() {
return foodRemStorage.getFoodRemFilePath();
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public Optional readFoodRem() throws DataConversionException, StorageFullException, IOException {
return readFoodRem(foodRemStorage.getFoodRemFilePath());
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public Optional readFoodRem(Path filePath) throws DataConversionException, IOException {
logger.fine("Attempting to read data from file: " + filePath);
return foodRemStorage.readFoodRem(filePath);
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void saveFoodRem(ReadOnlyFoodRem foodRem) throws IOException {
saveFoodRem(foodRem, foodRemStorage.getFoodRemFilePath());
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void saveFoodRem(ReadOnlyFoodRem foodRem, Path filePath) throws IOException {
logger.fine("Attempting to write to data file: " + filePath);
diff --git a/src/main/java/seedu/foodrem/ui/UiManager.java b/src/main/java/seedu/foodrem/ui/UiManager.java
index 1c4203f6a70..d9e2a581702 100644
--- a/src/main/java/seedu/foodrem/ui/UiManager.java
+++ b/src/main/java/seedu/foodrem/ui/UiManager.java
@@ -43,6 +43,9 @@ private static void showAlertDialogAndWait(
alert.showAndWait();
}
+ /**
+ * Shows Alert Dialog and wait.
+ */
void showAlertDialogAndWait(Alert.AlertType type, String title, String headerText, String contentText) {
showAlertDialogAndWait(mainWindow.getPrimaryStage(), type, title, headerText, contentText);
}
diff --git a/src/test/java/seedu/foodrem/testutil/FoodRemBuilder.java b/src/test/java/seedu/foodrem/testutil/FoodRemBuilder.java
index 3fa3387678e..1db341fb290 100644
--- a/src/test/java/seedu/foodrem/testutil/FoodRemBuilder.java
+++ b/src/test/java/seedu/foodrem/testutil/FoodRemBuilder.java
@@ -11,10 +11,16 @@
public class FoodRemBuilder {
private final FoodRem foodRem;
+ /**
+ * Constructs a FoodRemBuilder.
+ */
public FoodRemBuilder() {
foodRem = new FoodRem();
}
+ /**
+ * Constructs a FoodRemBuilder.
+ */
public FoodRemBuilder(FoodRem foodRem) {
this.foodRem = foodRem;
}
@@ -27,6 +33,9 @@ public FoodRemBuilder withItem(Item item) {
return this;
}
+ /**
+ * Builds a FoodRemBuilder.
+ */
public FoodRem build() {
return foodRem;
}
From a56a343534f5ac4808e21fd6c0ce9bf2cffdf96c Mon Sep 17 00:00:00 2001
From: Tan Yi Xian <>
Date: Sun, 6 Nov 2022 15:10:13 +0800
Subject: [PATCH 18/25] Add empty author tag to UserPrefs, Version and
SampleDataUtil
---
src/main/java/seedu/foodrem/commons/core/Version.java | 1 +
src/main/java/seedu/foodrem/model/UserPrefs.java | 1 +
src/main/java/seedu/foodrem/model/util/SampleDataUtil.java | 2 ++
3 files changed, 4 insertions(+)
diff --git a/src/main/java/seedu/foodrem/commons/core/Version.java b/src/main/java/seedu/foodrem/commons/core/Version.java
index 09a543d4fab..27e5a220b3d 100644
--- a/src/main/java/seedu/foodrem/commons/core/Version.java
+++ b/src/main/java/seedu/foodrem/commons/core/Version.java
@@ -8,6 +8,7 @@
/**
* Represents a version with major, minor and patch number
+ * @author
*/
public class Version implements Comparable {
private static final String VERSION_REGEX = "V(\\d+)\\.(\\d+)\\.(\\d+)(ea)?";
diff --git a/src/main/java/seedu/foodrem/model/UserPrefs.java b/src/main/java/seedu/foodrem/model/UserPrefs.java
index c0248481025..b1160e524a5 100644
--- a/src/main/java/seedu/foodrem/model/UserPrefs.java
+++ b/src/main/java/seedu/foodrem/model/UserPrefs.java
@@ -10,6 +10,7 @@
/**
* Represents User's preferences.
+ * @author
*/
public class UserPrefs implements ReadOnlyUserPrefs {
private GuiSettings guiSettings = new GuiSettings();
diff --git a/src/main/java/seedu/foodrem/model/util/SampleDataUtil.java b/src/main/java/seedu/foodrem/model/util/SampleDataUtil.java
index e13e0416e07..7a0c6ac2b10 100644
--- a/src/main/java/seedu/foodrem/model/util/SampleDataUtil.java
+++ b/src/main/java/seedu/foodrem/model/util/SampleDataUtil.java
@@ -17,6 +17,8 @@
/**
* Contains utility methods for populating {@code FoodRem} with sample data.
+ *
+ * @author
*/
public class SampleDataUtil {
public static Item[] getSampleItems() {
From 59244f255e874a5b3838b21bd15ac0e4f92729e7 Mon Sep 17 00:00:00 2001
From: Tan Yi Xian <>
Date: Sun, 6 Nov 2022 15:10:33 +0800
Subject: [PATCH 19/25] Add empty author tag to ItemsToSort
---
src/test/java/seedu/foodrem/testutil/ItemsToSort.java | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/test/java/seedu/foodrem/testutil/ItemsToSort.java b/src/test/java/seedu/foodrem/testutil/ItemsToSort.java
index c89846c9dc2..d98bcb13b5e 100644
--- a/src/test/java/seedu/foodrem/testutil/ItemsToSort.java
+++ b/src/test/java/seedu/foodrem/testutil/ItemsToSort.java
@@ -8,6 +8,8 @@
/**
* A utility class containing a list of {@code item} objects to be used in tests related to sorting.
+ *
+ * @author
*/
public class ItemsToSort {
public static final Item NI_Q1_U114_B119_E18_P13_R3 = new ItemBuilder().withItemName("NI Q1 U114 B119 E18 P13 R3")
From c8f1e6f5c497ff044a4a3f71da483983f9244a31 Mon Sep 17 00:00:00 2001
From: Tan Yi Xian <>
Date: Sun, 6 Nov 2022 15:10:43 +0800
Subject: [PATCH 20/25] Add javadoc to ItemPriceValidator
---
.../model/item/itemvalidators/ItemPriceValidator.java | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/main/java/seedu/foodrem/model/item/itemvalidators/ItemPriceValidator.java b/src/main/java/seedu/foodrem/model/item/itemvalidators/ItemPriceValidator.java
index 1a0bc803e76..c73fe1a989e 100644
--- a/src/main/java/seedu/foodrem/model/item/itemvalidators/ItemPriceValidator.java
+++ b/src/main/java/seedu/foodrem/model/item/itemvalidators/ItemPriceValidator.java
@@ -26,7 +26,10 @@ public static Void validate(String itemPriceString) {
"The item price should not be negative.");
}
- static Void validateNumericString(String numericString, int maxDecimalPlace, int maximum,
+ /**
+ * Validates a given numeric String. This is to be used during construction.
+ */
+ public static Void validateNumericString(String numericString, int maxDecimalPlace, int maximum,
String messageNotANumber, String messageTooPrecise, String messageTooLarge,
String messageIsNegative) {
boolean isParsable = ValidationUtil.isParsableDouble(numericString);
From eabf24e955d7ccf713d4930bd82fb69460ef053a Mon Sep 17 00:00:00 2001
From: Tan Yi Xian <>
Date: Sun, 6 Nov 2022 15:10:53 +0800
Subject: [PATCH 21/25] Add javadoc to NameContainsKeywordsPredicate
---
.../model/item/NameContainsKeywordsPredicate.java | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/src/main/java/seedu/foodrem/model/item/NameContainsKeywordsPredicate.java b/src/main/java/seedu/foodrem/model/item/NameContainsKeywordsPredicate.java
index 39a67309abc..054254d24b2 100644
--- a/src/main/java/seedu/foodrem/model/item/NameContainsKeywordsPredicate.java
+++ b/src/main/java/seedu/foodrem/model/item/NameContainsKeywordsPredicate.java
@@ -11,16 +11,25 @@
public class NameContainsKeywordsPredicate implements Predicate
- {
private final List keywords;
+ /**
+ * Constructs a {@link NameContainsKeywordsPredicate}.
+ */
public NameContainsKeywordsPredicate(List keywords) {
this.keywords = keywords;
}
+ /**
+ * Tests if the item name matches all the keywords.
+ */
@Override
public boolean test(Item item) {
return keywords.stream()
.allMatch(keyword -> StringUtil.containsSubstringIgnoreCase(item.getName().toString(), keyword));
}
+ /**
+ * Returns {@code true} if both {@link NameContainsKeywordsPredicate} have the same keywords.
+ */
@Override
public boolean equals(Object other) {
return other == this
From b04a7e7850f889897f44c71cd185a3770bb0223e Mon Sep 17 00:00:00 2001
From: Tan Yi Xian <>
Date: Sun, 6 Nov 2022 15:11:09 +0800
Subject: [PATCH 22/25] Add javadoc to TypicalItems
---
src/test/java/seedu/foodrem/testutil/TypicalItems.java | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/src/test/java/seedu/foodrem/testutil/TypicalItems.java b/src/test/java/seedu/foodrem/testutil/TypicalItems.java
index 63df6a2151a..567c7533080 100644
--- a/src/test/java/seedu/foodrem/testutil/TypicalItems.java
+++ b/src/test/java/seedu/foodrem/testutil/TypicalItems.java
@@ -57,12 +57,18 @@ public class TypicalItems {
private TypicalItems() {
} // prevents instantiation
+ /**
+ * Returns a list of typical items.
+ */
public static List
- getTypicalItems() {
// WARNING: Ensure all items have a vegetable tag.
// Failure to do so will break test cases.
return new ArrayList<>(Arrays.asList(POTATOES, CUCUMBERS));
}
+ /**
+ * Returns a list of typical items without tags.
+ */
public static List
- getTypicalItemsWithoutTags() {
return new ArrayList<>(Arrays.asList(POTATOES_WITHOUT_TAG, CUCUMBERS_WITHOUT_TAG));
}
From 86a74a9a55a09dcce66d374876f8c0c82ef65052 Mon Sep 17 00:00:00 2001
From: Tan Yi Xian <>
Date: Sun, 6 Nov 2022 15:32:18 +0800
Subject: [PATCH 23/25] Fix test toModelType to catch correct error
---
.../foodrem/storage/JsonAdaptedItem.java | 31 ++++++++++---------
1 file changed, 17 insertions(+), 14 deletions(-)
diff --git a/src/main/java/seedu/foodrem/storage/JsonAdaptedItem.java b/src/main/java/seedu/foodrem/storage/JsonAdaptedItem.java
index d6f18203453..b62c005a773 100644
--- a/src/main/java/seedu/foodrem/storage/JsonAdaptedItem.java
+++ b/src/main/java/seedu/foodrem/storage/JsonAdaptedItem.java
@@ -1,7 +1,6 @@
package seedu.foodrem.storage;
import java.util.ArrayList;
-import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.Set;
@@ -78,19 +77,23 @@ public JsonAdaptedItem(Item source) {
*/
public Item toModelType() throws IllegalArgumentException {
checkIfFieldsAreNull();
-
- final Set modelTags = new HashSet<>();
- modelTags.addAll(tags.stream().map(JsonAdaptedTag::toModelType).collect(Collectors.toList()));
-
- return new Item(
- new ItemName(name),
- new ItemQuantity(quantity),
- new ItemUnit(unit),
- ItemBoughtDate.of(boughtDate),
- ItemExpiryDate.of(expiryDate),
- new ItemPrice(price),
- new ItemRemark(remarks),
- modelTags);
+ final ItemName modelItemName = new ItemName(name);
+ final ItemQuantity modelItemQuantity = new ItemQuantity(quantity);
+ final ItemUnit modelItemUnit = new ItemUnit(unit);
+ final ItemBoughtDate modelItemBoughtDate = ItemBoughtDate.of(boughtDate);
+ final ItemExpiryDate modelItemExpiryDate = ItemExpiryDate.of(expiryDate);
+ final ItemPrice modelItemPrice = new ItemPrice(price);
+ final ItemRemark modelItemRemark = new ItemRemark(remarks);
+ final Set modelTags = tags.stream()
+ .map(JsonAdaptedTag::toModelType).collect(Collectors.toSet());
+ return new Item(modelItemName,
+ modelItemQuantity,
+ modelItemUnit,
+ modelItemBoughtDate,
+ modelItemExpiryDate,
+ modelItemPrice,
+ modelItemRemark,
+ modelTags);
}
/**
From d101ce625030e022cb1b036a5b0f3063467e96a4 Mon Sep 17 00:00:00 2001
From: Tan Yi Xian <>
Date: Sun, 6 Nov 2022 16:22:35 +0800
Subject: [PATCH 24/25] Add assertions to Item
---
src/main/java/seedu/foodrem/model/item/Item.java | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/src/main/java/seedu/foodrem/model/item/Item.java b/src/main/java/seedu/foodrem/model/item/Item.java
index 0b3a2bc679d..22ac52eae82 100644
--- a/src/main/java/seedu/foodrem/model/item/Item.java
+++ b/src/main/java/seedu/foodrem/model/item/Item.java
@@ -98,6 +98,7 @@ public static Item createItemWithTags(Item item, Set tags) {
* Returns the item name.
*/
public ItemName getName() {
+ assert name != null;
return name;
}
@@ -105,6 +106,7 @@ public ItemName getName() {
* Returns the item quantity.
*/
public ItemQuantity getQuantity() {
+ assert quantity != null;
return quantity;
}
@@ -112,6 +114,7 @@ public ItemQuantity getQuantity() {
* Returns the item unit.
*/
public ItemUnit getUnit() {
+ assert unit != null;
return unit;
}
@@ -119,6 +122,7 @@ public ItemUnit getUnit() {
* Returns the item bought date.
*/
public ItemBoughtDate getBoughtDate() {
+ assert boughtDate != null;
return boughtDate;
}
@@ -126,6 +130,7 @@ public ItemBoughtDate getBoughtDate() {
* Returns the item expiry date.
*/
public ItemExpiryDate getExpiryDate() {
+ assert expiryDate != null;
return expiryDate;
}
@@ -133,6 +138,7 @@ public ItemExpiryDate getExpiryDate() {
* Returns the item price.
*/
public ItemPrice getPrice() {
+ assert price != null;
return price;
}
@@ -140,6 +146,7 @@ public ItemPrice getPrice() {
* Returns the item remarks.
*/
public ItemRemark getRemarks() {
+ assert remarks != null;
return remarks;
}
@@ -149,6 +156,7 @@ public ItemRemark getRemarks() {
* @return The total value of purchasing the specified units of the item.
*/
public boolean isExpired() {
+ assert expiryDate != null;
return expiryDate.isAfterOrOnDate(LocalDate.now());
}
@@ -158,6 +166,7 @@ public boolean isExpired() {
* @return The total value of purchasing the specified units of the item.
*/
public boolean hasNonZeroQuantity() {
+ assert quantity != null;
return !quantity.isZero();
}
@@ -167,6 +176,7 @@ public boolean hasNonZeroQuantity() {
* @return The total value of purchasing the specified units of the item.
*/
public double getItemValue() {
+ assert price != null && quantity != null;
// TODO: Possibly refactor to avoid using getter methods in ItemPrice and ItemQuantity fields
return price.getItemPrice() * quantity.getItemQuantity();
}
@@ -177,6 +187,7 @@ public double getItemValue() {
* @return a new set containing the tags of this item.
*/
public Set getTagSet() {
+ assert tagSet != null;
// Instantiate new set to preserve immutability of item.
return new HashSet<>(tagSet);
}
From e759b0c37e8ea791b7121840b6cbefddb3455eb9 Mon Sep 17 00:00:00 2001
From: Tan Yi Xian <>
Date: Sun, 6 Nov 2022 20:18:22 +0800
Subject: [PATCH 25/25] Remove public access modifier
---
.../foodrem/model/item/itemvalidators/ItemPriceValidator.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/main/java/seedu/foodrem/model/item/itemvalidators/ItemPriceValidator.java b/src/main/java/seedu/foodrem/model/item/itemvalidators/ItemPriceValidator.java
index c73fe1a989e..089c39baf4d 100644
--- a/src/main/java/seedu/foodrem/model/item/itemvalidators/ItemPriceValidator.java
+++ b/src/main/java/seedu/foodrem/model/item/itemvalidators/ItemPriceValidator.java
@@ -29,7 +29,7 @@ public static Void validate(String itemPriceString) {
/**
* Validates a given numeric String. This is to be used during construction.
*/
- public static Void validateNumericString(String numericString, int maxDecimalPlace, int maximum,
+ static Void validateNumericString(String numericString, int maxDecimalPlace, int maximum,
String messageNotANumber, String messageTooPrecise, String messageTooLarge,
String messageIsNegative) {
boolean isParsable = ValidationUtil.isParsableDouble(numericString);