diff --git a/docs/UserGuide.md b/docs/UserGuide.md
index 97bb6cd6bcf..ca20231e057 100644
--- a/docs/UserGuide.md
+++ b/docs/UserGuide.md
@@ -39,8 +39,6 @@ with it using a CLI, and it has a GUI created with JavaFX.
## Features
-
-
**Notes about the command format:**
@@ -58,7 +56,6 @@ with it using a CLI, and it has a GUI created with JavaFX.
e.g. if the command specifies `help 123`, it will be interpreted as `help`.
* If you are using a PDF version of this document, be careful when copying and pasting commands that span multiple lines as space characters surrounding line-breaks may be omitted when copied over to the application.
-
### Viewing help : `help`
diff --git a/src/main/java/seedu/address/model/ModelManager.java b/src/main/java/seedu/address/model/ModelManager.java
index dd3b6ac8250..6456b939f90 100644
--- a/src/main/java/seedu/address/model/ModelManager.java
+++ b/src/main/java/seedu/address/model/ModelManager.java
@@ -116,7 +116,7 @@ public void setModule(Module target, Module editedModule) {
//=========== Filtered Person List Accessors =============================================================
/**
- * Returns an unmodifiable view of the list of {@code Person} backed by the internal list of
+ * Returns an unmodifiable view of the list of {@code Module} backed by the internal list of
* {@code versionedAddressBook}
*/
@Override
diff --git a/src/main/java/seedu/address/model/module/Module.java b/src/main/java/seedu/address/model/module/Module.java
index 633482320a6..32f97a9e0a5 100644
--- a/src/main/java/seedu/address/model/module/Module.java
+++ b/src/main/java/seedu/address/model/module/Module.java
@@ -3,6 +3,7 @@
import static seedu.address.commons.util.CollectionUtil.requireAllNonNull;
import java.util.List;
+import java.util.Set;
/**
* Represents a Module in the system.
@@ -15,7 +16,7 @@ public class Module {
// Data fields
private final Description description;
- private final List lecturers;
+ private final Set lecturers;
private final Year yearTaken;
private final Semester semesterTaken;
private final Grade grade;
@@ -24,9 +25,8 @@ public class Module {
/**
* Every field must be present and not null.
*/
- public Module(
- ModuleName name, ModuleCode moduleCode, Description description, List lecturers,
- Year yearTaken, Semester semesterTaken, Grade grade, ModularCredit modularCredit) {
+ public Module(ModuleCode moduleCode, Year yearTaken, Semester semesterTaken, Grade grade, ModuleName name,
+ Description description, Set lecturers, ModularCredit modularCredit) {
requireAllNonNull(name, moduleCode, description, lecturers, yearTaken, semesterTaken, grade);
this.moduleName = name;
this.moduleCode = moduleCode;
@@ -62,7 +62,7 @@ public Description getDescription() {
return description;
}
- public List getLecturers() {
+ public Set getLecturers() {
return lecturers;
}
diff --git a/src/main/java/seedu/address/storage/JsonAdaptedLecturer.java b/src/main/java/seedu/address/storage/JsonAdaptedLecturer.java
new file mode 100644
index 00000000000..ac52ffd2430
--- /dev/null
+++ b/src/main/java/seedu/address/storage/JsonAdaptedLecturer.java
@@ -0,0 +1,47 @@
+package seedu.address.storage;
+
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonValue;
+import seedu.address.commons.exceptions.IllegalValueException;
+import seedu.address.model.module.Lecturer;
+
+/**
+ * Jackson-friendly version of {@link Lecturer}.
+ */
+public class JsonAdaptedLecturer {
+ private final String lecturerName;
+
+ /**
+ * Constructs a {@code JsonAdaptedLecturer} with the given {@code lecturerName}.
+ */
+ @JsonCreator
+ public JsonAdaptedLecturer(String lecturerName) {
+ this.lecturerName = lecturerName;
+ }
+
+ /**
+ * Converts a given {@code Lecturer} into this class for Jackson use.
+ */
+ public JsonAdaptedLecturer(Lecturer source) {
+ lecturerName = source.lecturerName;
+ }
+
+ @JsonValue
+ public String getLecturerName() {
+ return lecturerName;
+ }
+
+ /**
+ * Converts this Jackson-friendly adapted tag object into the model's {@code Tag} object.
+ *
+ * @throws IllegalValueException if there were any data constraints violated in the adapted tag.
+ */
+ public Lecturer toModelType() throws IllegalValueException {
+ if (!Lecturer.isValidLecturer(lecturerName)) {
+ throw new IllegalValueException(Lecturer.MESSAGE_CONSTRAINTS);
+ }
+ return new Lecturer(lecturerName);
+ }
+
+}
diff --git a/src/main/java/seedu/address/storage/JsonAdaptedModule.java b/src/main/java/seedu/address/storage/JsonAdaptedModule.java
new file mode 100644
index 00000000000..b1cf5179552
--- /dev/null
+++ b/src/main/java/seedu/address/storage/JsonAdaptedModule.java
@@ -0,0 +1,131 @@
+package seedu.address.storage;
+
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import seedu.address.commons.exceptions.IllegalValueException;
+import seedu.address.model.module.*;
+import seedu.address.model.module.Module;
+import seedu.address.model.person.*;
+import seedu.address.model.tag.Tag;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+/**
+ * Jackson-friendly version of {@link Module}.
+ */
+public class JsonAdaptedModule {
+ public static final String MISSING_FIELD_MESSAGE_FORMAT = "Module's %s field is missing!";
+
+ private final String code;
+ private final String year;
+ private final String sem;
+ private final String grade;
+ private final String name;
+ private final String description;
+ private final List lecturers = new ArrayList<>();
+
+ /**
+ * Constructs a {@code JsonAdaptedModule} with the given module details.
+ */
+
+ @JsonCreator
+ public JsonAdaptedModule(@JsonProperty("code") String code, @JsonProperty("year") String year,
+ @JsonProperty("sem") String sem, @JsonProperty("grade") String grade,
+ @JsonProperty("name") String name,
+ @JsonProperty("description") String description,
+ @JsonProperty("lecturers") List lecturers) {
+ this.code = code;
+ this.year = year;
+ this.sem = sem;
+ this.grade = grade;
+ this.name = name;
+ this.description = description;
+ if (lecturers != null) {
+ this.lecturers.addAll(lecturers);
+ }
+ }
+ /**
+ * Converts a given {@code Module} into this class for Jackson use.
+ */
+ public JsonAdaptedModule(Module source) {
+ code = source.getModuleCode().toString();
+ year = source.getYearTaken().toString();
+ sem = source.getSemesterTaken().toString();
+ grade = source.getGrade().toString();
+ name = source.getName().toString();
+ description = source.getDescription().toString();
+ lecturers.addAll(source.getLecturers().stream()
+ .map(JsonAdaptedLecturer::new)
+ .collect(Collectors.toList()));
+ }
+
+ /**
+ * Converts this Jackson-friendly adapted person object into the model's {@code Person} object.
+ *
+ * @throws IllegalValueException if there were any data constraints violated in the adapted person.
+ */
+ public Module toModelType() throws IllegalValueException {
+ final List moduleLecturers = new ArrayList<>();
+ for (JsonAdaptedLecturer lecturer : lecturers) {
+ moduleLecturers.add(lecturer.toModelType());
+ }
+
+ if (code == null) {
+ throw new IllegalValueException(String.format(MISSING_FIELD_MESSAGE_FORMAT, ModuleCode.class.getSimpleName()));
+ }
+ if (!ModuleCode.isValidModuleCode(code)) {
+ throw new IllegalValueException(ModuleCode.MESSAGE_CONSTRAINTS);
+ }
+ final ModuleCode modelCode = new ModuleCode(code);
+
+
+ if (year == null) {
+ throw new IllegalValueException(String.format(MISSING_FIELD_MESSAGE_FORMAT, Year.class.getSimpleName()));
+ }
+ if (!Year.isValidYear(year)) {
+ throw new IllegalValueException(Year.MESSAGE_CONSTRAINTS);
+ }
+ final Year modelYear = new Year(year);
+
+ if (sem == null) {
+ throw new IllegalValueException(String.format(MISSING_FIELD_MESSAGE_FORMAT, Semester.class.getSimpleName()));
+ }
+ if (!Semester.isValidSemester(sem)) {
+ throw new IllegalValueException(Semester.MESSAGE_CONSTRAINTS);
+ }
+ final Semester modelSem = new Semester(sem);
+
+ if (grade == null) {
+ throw new IllegalValueException(String.format(MISSING_FIELD_MESSAGE_FORMAT, Grade.class.getSimpleName()));
+ }
+ if (!Grade.isValidGrade(grade)) {
+ throw new IllegalValueException(Grade.MESSAGE_CONSTRAINTS);
+ }
+ final Grade modelGrade = new Grade(grade);
+
+ if(name == null) {
+ throw new IllegalValueException(String.format(MISSING_FIELD_MESSAGE_FORMAT, ModuleName.class.getSimpleName()));
+ }
+ if (!ModuleName.isValidName(name)) {
+ throw new IllegalValueException(ModuleName.MESSAGE_CONSTRAINTS);
+ }
+ final ModuleName modelName = new ModuleName(name);
+
+ if (description == null) {
+ throw new IllegalValueException(String.format(MISSING_FIELD_MESSAGE_FORMAT, Description.class.getSimpleName()));
+ }
+ if(!Description.isValidDescription(description)) {
+ throw new IllegalValueException(Description.MESSAGE_CONSTRAINTS);
+ }
+ final Description modelDescription = new Description(description);
+
+ final Set modelLecturer = new HashSet<>(moduleLecturers);
+ return new Module(modelCode, modelYear, modelSem, modelGrade, modelName, modelDescription, modelLecturer);
+ }
+
+}
diff --git a/src/main/java/seedu/address/storage/JsonSerializableAddressBook.java b/src/main/java/seedu/address/storage/JsonSerializableAddressBook.java
index 5efd834091d..5b2c18d0b01 100644
--- a/src/main/java/seedu/address/storage/JsonSerializableAddressBook.java
+++ b/src/main/java/seedu/address/storage/JsonSerializableAddressBook.java
@@ -11,6 +11,7 @@
import seedu.address.commons.exceptions.IllegalValueException;
import seedu.address.model.AddressBook;
import seedu.address.model.ReadOnlyAddressBook;
+import seedu.address.model.module.Module;
import seedu.address.model.person.Person;
/**
@@ -19,16 +20,17 @@
@JsonRootName(value = "addressbook")
class JsonSerializableAddressBook {
- public static final String MESSAGE_DUPLICATE_PERSON = "Persons list contains duplicate person(s).";
+ public static final String MESSAGE_DUPLICATE_MODULE = "Module list contains duplicate module(s).";
private final List persons = new ArrayList<>();
+ private final List modules = new ArrayList<>();
/**
* Constructs a {@code JsonSerializableAddressBook} with the given persons.
*/
@JsonCreator
- public JsonSerializableAddressBook(@JsonProperty("persons") List persons) {
- this.persons.addAll(persons);
+ public JsonSerializableAddressBook(@JsonProperty("module") List modules) {
+ this.modules.addAll(modules);
}
/**
@@ -37,7 +39,7 @@ public JsonSerializableAddressBook(@JsonProperty("persons") List