src/main/java/seedu/address/storage/storageCourse/JsonAdaptedCourse.java
public Course toModelType() throws IllegalValueException, CommandException {
        if (name == null) {
            throw new IllegalValueException(
                    String.format(MISSING_FIELD_MESSAGE_FORMAT, Name.class.getSimpleName()));
        }
        if (!Name.isValidName(name)) {
            throw new IllegalValueException(Name.MESSAGE_CONSTRAINTS);
        }
        final Name modelName = new Name(name);

        if (courseID == null) {
            throw new IllegalValueException(
                    String.format(MISSING_FIELD_MESSAGE_FORMAT, ID.class.getSimpleName()));
        }
        if (!ID.isValidId(courseID)) {
            throw new IllegalValueException(ID.MESSAGE_CONSTRAINTS);
        }
        final ID modelId = new ID(courseID);

        if (amount == null) {
            throw new IllegalValueException(
                    String.format(MISSING_FIELD_MESSAGE_FORMAT, Amount.class.getSimpleName()));
        }
        if (!Amount.isValidAmount(amount)) {
            throw new IllegalValueException(Amount.MESSAGE_CONSTRAINTS);
        }
        final Amount modelAmount = new Amount(amount);

        if (assignedStaff == null) {
            throw new IllegalValueException(
                    String.format(MISSING_FIELD_MESSAGE_FORMAT, AssignedStaff.class.getSimpleName()));
        }
        if (!AssignedStaff.isValidAssignedStaff(assignedStaff)) {
            throw new IllegalValueException(AssignedStaff.MESSAGE_CONSTRAINTS);
        }
        final ID modelAssignedStaff = new ID(assignedStaff);

        final List<ID> CourseAssignedStudentsID = new ArrayList<>();
        for (JsonCourseAdaptedID id : assignedStudentsID) {
            CourseAssignedStudentsID.add(id.toModelType());
        }
        final Set<ID> modelAssignedStudentsID = new HashSet<>(CourseAssignedStudentsID);

        final List<ID> CourseAssignedAssignmentsID = new ArrayList<>();
        for (JsonCourseAdaptedID id : assignedAssignmentsID) {
            CourseAssignedAssignmentsID.add(id.toModelType());
        }
        final Set<ID> modelAssignedAssignmentsID = new HashSet<>(CourseAssignedAssignmentsID);


        final List<Tag> CourseTags = new ArrayList<>();
        for (JsonCourseAdaptedTag tag : tagged) {
            CourseTags.add(tag.toModelType());
        }
        final Set<Tag> modelTags = new HashSet<>(CourseTags);

        Course courseReadFromFile = new Course(modelName, modelId, modelAmount, modelTags);

        courseReadFromFile.addStaff(modelAssignedStaff);
        courseReadFromFile.addStudents(modelAssignedStudentsID);
        courseReadFromFile.addAssignments(modelAssignedAssignmentsID);

        return courseReadFromFile;
    }
/**
     * Converts this Jackson-friendly adapted Assignment object into the model's {@code Assignment} object.
     *
     * @throws IllegalValueException if there were any data constraints violated in the adapted
     *                               Assignment.
     */
Converts this Jackson-friendly adapted Assignment object into the model's  Assignment object.
@throws IllegalValueException if there were any data constraints violated in the adapted
Assignment.
Converts this Jackson - friendly adapted Assignment object into the model ' s Assignment object . @throws IllegalValueException if there were any data constraints violated in the adapted Assignment .
public Course toModelType() throws IllegalValueException, CommandException {
        if (name == null) {
            throw new IllegalValueException(
                    String.format(MISSING_FIELD_MESSAGE_FORMAT, Name.class.getSimpleName()));
        }
        if (!Name.isValidName(name)) {
            throw new IllegalValueException(Name.MESSAGE_CONSTRAINTS);
        }
        final Name modelName = new Name(name);
        if (courseID == null) {
            throw new IllegalValueException(
                    String.format(MISSING_FIELD_MESSAGE_FORMAT, ID.class.getSimpleName()));
        }
        if (!ID.isValidId(courseID)) {
            throw new IllegalValueException(ID.MESSAGE_CONSTRAINTS);
        }
        final ID modelId = new ID(courseID);
        if (amount == null) {
            throw new IllegalValueException(
                    String.format(MISSING_FIELD_MESSAGE_FORMAT, Amount.class.getSimpleName()));
        }
        if (!Amount.isValidAmount(amount)) {
            throw new IllegalValueException(Amount.MESSAGE_CONSTRAINTS);
        }
        final Amount modelAmount = new Amount(amount);
        if (assignedStaff == null) {
            throw new IllegalValueException(
                    String.format(MISSING_FIELD_MESSAGE_FORMAT, AssignedStaff.class.getSimpleName()));
        }
        if (!AssignedStaff.isValidAssignedStaff(assignedStaff)) {
            throw new IllegalValueException(AssignedStaff.MESSAGE_CONSTRAINTS);
        }
        final ID modelAssignedStaff = new ID(assignedStaff);
        final List<ID> CourseAssignedStudentsID = new ArrayList<>();
        for (JsonCourseAdaptedID id : assignedStudentsID) {
            CourseAssignedStudentsID.add(id.toModelType());
        }
        final Set<ID> modelAssignedStudentsID = new HashSet<>(CourseAssignedStudentsID);
        final List<ID> CourseAssignedAssignmentsID = new ArrayList<>();
        for (JsonCourseAdaptedID id : assignedAssignmentsID) {
            CourseAssignedAssignmentsID.add(id.toModelType());
        }
        final Set<ID> modelAssignedAssignmentsID = new HashSet<>(CourseAssignedAssignmentsID);
        final List<Tag> CourseTags = new ArrayList<>();
        for (JsonCourseAdaptedTag tag : tagged) {
            CourseTags.add(tag.toModelType());
        }
        final Set<Tag> modelTags = new HashSet<>(CourseTags);
        Course courseReadFromFile = new Course(modelName, modelId, modelAmount, modelTags);
        courseReadFromFile.addStaff(modelAssignedStaff);
        courseReadFromFile.addStudents(modelAssignedStudentsID);
        courseReadFromFile.addAssignments(modelAssignedAssignmentsID);
        return courseReadFromFile;
    }
public Course toModelType ( ) throws IllegalValueException , CommandException { if ( name == null ) { throw new IllegalValueException ( String . format ( MISSING_FIELD_MESSAGE_FORMAT , Name . class . getSimpleName ( ) ) ) ; } if ( ! Name . isValidName ( name ) ) { throw new IllegalValueException ( Name . MESSAGE_CONSTRAINTS ) ; } final Name modelName = new Name ( name ) ; if ( courseID == null ) { throw new IllegalValueException ( String . format ( MISSING_FIELD_MESSAGE_FORMAT , ID . class . getSimpleName ( ) ) ) ; } if ( ! ID . isValidId ( courseID ) ) { throw new IllegalValueException ( ID . MESSAGE_CONSTRAINTS ) ; } final ID modelId = new ID ( courseID ) ; if ( amount == null ) { throw new IllegalValueException ( String . format ( MISSING_FIELD_MESSAGE_FORMAT , Amount . class . getSimpleName ( ) ) ) ; } if ( ! Amount . isValidAmount ( amount ) ) { throw new IllegalValueException ( Amount . MESSAGE_CONSTRAINTS ) ; } final Amount modelAmount = new Amount ( amount ) ; if ( assignedStaff == null ) { throw new IllegalValueException ( String . format ( MISSING_FIELD_MESSAGE_FORMAT , AssignedStaff . class . getSimpleName ( ) ) ) ; } if ( ! AssignedStaff . isValidAssignedStaff ( assignedStaff ) ) { throw new IllegalValueException ( AssignedStaff . MESSAGE_CONSTRAINTS ) ; } final ID modelAssignedStaff = new ID ( assignedStaff ) ; final List < ID > CourseAssignedStudentsID = new ArrayList < > ( ) ; for ( JsonCourseAdaptedID id : assignedStudentsID ) { CourseAssignedStudentsID . add ( id . toModelType ( ) ) ; } final Set < ID > modelAssignedStudentsID = new HashSet < > ( CourseAssignedStudentsID ) ; final List < ID > CourseAssignedAssignmentsID = new ArrayList < > ( ) ; for ( JsonCourseAdaptedID id : assignedAssignmentsID ) { CourseAssignedAssignmentsID . add ( id . toModelType ( ) ) ; } final Set < ID > modelAssignedAssignmentsID = new HashSet < > ( CourseAssignedAssignmentsID ) ; final List < Tag > CourseTags = new ArrayList < > ( ) ; for ( JsonCourseAdaptedTag tag : tagged ) { CourseTags . add ( tag . toModelType ( ) ) ; } final Set < Tag > modelTags = new HashSet < > ( CourseTags ) ; Course courseReadFromFile = new Course ( modelName , modelId , modelAmount , modelTags ) ; courseReadFromFile . addStaff ( modelAssignedStaff ) ; courseReadFromFile . addStudents ( modelAssignedStudentsID ) ; courseReadFromFile . addAssignments ( modelAssignedAssignmentsID ) ; return courseReadFromFile ; }
Converts this Jackson-friendly adapted Assignment object into the model's {@code Assignment} object.
Converts this Jackson - friendly adapted Assignment object into the model ' s { @code Assignment } object .