src/main/java/seedu/address/storage/storageStaff/JsonAdaptedStaff.java
public Staff toModelType() throws IllegalValueException {
        final List<Tag> staffTags = new ArrayList<>();
        for (JsonStaffAdaptedTag tag : tagged) {
            staffTags.add(tag.toModelType());
        }
        final Set<Tag> modelTags = new HashSet<>(staffTags);

        final List<ID> TeacherAssignedCoursesID = new ArrayList<>();
        for (JsonStaffAdaptedID id : assignedCoursesID) {
            TeacherAssignedCoursesID.add(id.toModelType());
        }
        final Set<ID> modelAssignedCoursesID = new HashSet<>(TeacherAssignedCoursesID);

        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 (gender == null) {
            throw new IllegalValueException(
                    String.format(MISSING_FIELD_MESSAGE_FORMAT, Gender.class.getSimpleName()));
        }
        if (!Gender.isValidGender(gender)) {
            throw new IllegalValueException(Gender.MESSAGE_CONSTRAINTS);
        }
        final Gender modelGender = new Gender(gender);

        if (level == null) {
            throw new IllegalValueException("Missing level field, unidentified Staff");
        }
    /*
    if (!level.equals("TEACHER") || !level.equals("ADMIN")) {
      throw new IllegalValueException("Wrong level field for staff, level should be saved as 0 or 1");
    }
     */
        Staff.Level modelLevel = Staff.Level.TEACHER;
        if (level.equals("ADMIN")) {
            modelLevel = Staff.Level.ADMIN;
        }
        if (!ID.isValidId(id)) {
            throw new IllegalValueException(ID.MESSAGE_CONSTRAINTS);
        }
        final ID modelID = new ID(id);

        if (phone == null) {
            throw new IllegalValueException(
                    String.format(MISSING_FIELD_MESSAGE_FORMAT, Phone.class.getSimpleName()));
        }
        if (!Phone.isValidPhone(phone)) {
            throw new IllegalValueException(Phone.MESSAGE_CONSTRAINTS);
        }
        final Phone modelPhone = new Phone(phone);

        if (email == null) {
            throw new IllegalValueException(
                    String.format(MISSING_FIELD_MESSAGE_FORMAT, Email.class.getSimpleName()));
        }
        if (!Email.isValidEmail(email)) {
            throw new IllegalValueException(Email.MESSAGE_CONSTRAINTS);
        }
        final Email modelEmail = new Email(email);

        if (!Salary.isValidSalary(salary)) {
            throw new IllegalValueException(Salary.MESSAGE_CONSTRAINTS);
        }
        final Salary modelSalary = new Salary(salary);

        if (address == null) {
            throw new IllegalValueException(
                    String.format(MISSING_FIELD_MESSAGE_FORMAT, Address.class.getSimpleName()));
        }
        if (!Address.isValidAddress(address)) {
            throw new IllegalValueException(Address.MESSAGE_CONSTRAINTS);
        }
        final Address modelAddress = new Address(address);
        return new Staff(modelName, modelID, modelGender, modelLevel, modelPhone, modelEmail, modelSalary, modelAddress, modelAssignedCoursesID, modelTags);
    }
/**
     * Converts this Jackson-friendly adapted staff object into the model's {@code Staff} object.
     *
     * @throws IllegalValueException if there were any data constraints violated in the adapted
     *                               staff.
     */
Converts this Jackson-friendly adapted staff object into the model's  Staff object.
@throws IllegalValueException if there were any data constraints violated in the adapted
staff.
Converts this Jackson - friendly adapted staff object into the model ' s Staff object . @throws IllegalValueException if there were any data constraints violated in the adapted staff .
public Staff toModelType() throws IllegalValueException {
        final List<Tag> staffTags = new ArrayList<>();
        for (JsonStaffAdaptedTag tag : tagged) {
            staffTags.add(tag.toModelType());
        }
        final Set<Tag> modelTags = new HashSet<>(staffTags);
        final List<ID> TeacherAssignedCoursesID = new ArrayList<>();
        for (JsonStaffAdaptedID id : assignedCoursesID) {
            TeacherAssignedCoursesID.add(id.toModelType());
        }
        final Set<ID> modelAssignedCoursesID = new HashSet<>(TeacherAssignedCoursesID);
        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 (gender == null) {
            throw new IllegalValueException(
                    String.format(MISSING_FIELD_MESSAGE_FORMAT, Gender.class.getSimpleName()));
        }
        if (!Gender.isValidGender(gender)) {
            throw new IllegalValueException(Gender.MESSAGE_CONSTRAINTS);
        }
        final Gender modelGender = new Gender(gender);
        if (level == null) {
            throw new IllegalValueException("Missing level field, unidentified Staff");
        }
    /*
    if (!level.equals("TEACHER") || !level.equals("ADMIN")) {
      throw new IllegalValueException("Wrong level field for staff, level should be saved as 0 or 1");
    }
     */
        Staff.Level modelLevel = Staff.Level.TEACHER;
        if (level.equals("ADMIN")) {
            modelLevel = Staff.Level.ADMIN;
        }
        if (!ID.isValidId(id)) {
            throw new IllegalValueException(ID.MESSAGE_CONSTRAINTS);
        }
        final ID modelID = new ID(id);
        if (phone == null) {
            throw new IllegalValueException(
                    String.format(MISSING_FIELD_MESSAGE_FORMAT, Phone.class.getSimpleName()));
        }
        if (!Phone.isValidPhone(phone)) {
            throw new IllegalValueException(Phone.MESSAGE_CONSTRAINTS);
        }
        final Phone modelPhone = new Phone(phone);
        if (email == null) {
            throw new IllegalValueException(
                    String.format(MISSING_FIELD_MESSAGE_FORMAT, Email.class.getSimpleName()));
        }
        if (!Email.isValidEmail(email)) {
            throw new IllegalValueException(Email.MESSAGE_CONSTRAINTS);
        }
        final Email modelEmail = new Email(email);
        if (!Salary.isValidSalary(salary)) {
            throw new IllegalValueException(Salary.MESSAGE_CONSTRAINTS);
        }
        final Salary modelSalary = new Salary(salary);
        if (address == null) {
            throw new IllegalValueException(
                    String.format(MISSING_FIELD_MESSAGE_FORMAT, Address.class.getSimpleName()));
        }
        if (!Address.isValidAddress(address)) {
            throw new IllegalValueException(Address.MESSAGE_CONSTRAINTS);
        }
        final Address modelAddress = new Address(address);
        return new Staff(modelName, modelID, modelGender, modelLevel, modelPhone, modelEmail, modelSalary, modelAddress, modelAssignedCoursesID, modelTags);
    }
public Staff toModelType ( ) throws IllegalValueException { final List < Tag > staffTags = new ArrayList < > ( ) ; for ( JsonStaffAdaptedTag tag : tagged ) { staffTags . add ( tag . toModelType ( ) ) ; } final Set < Tag > modelTags = new HashSet < > ( staffTags ) ; final List < ID > TeacherAssignedCoursesID = new ArrayList < > ( ) ; for ( JsonStaffAdaptedID id : assignedCoursesID ) { TeacherAssignedCoursesID . add ( id . toModelType ( ) ) ; } final Set < ID > modelAssignedCoursesID = new HashSet < > ( TeacherAssignedCoursesID ) ; 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 ( gender == null ) { throw new IllegalValueException ( String . format ( MISSING_FIELD_MESSAGE_FORMAT , Gender . class . getSimpleName ( ) ) ) ; } if ( ! Gender . isValidGender ( gender ) ) { throw new IllegalValueException ( Gender . MESSAGE_CONSTRAINTS ) ; } final Gender modelGender = new Gender ( gender ) ; if ( level == null ) { throw new IllegalValueException ( "Missing level field, unidentified Staff" ) ; } /*
    if (!level.equals("TEACHER") || !level.equals("ADMIN")) {
      throw new IllegalValueException("Wrong level field for staff, level should be saved as 0 or 1");
    }
     */ Staff . Level modelLevel = Staff . Level . TEACHER ; if ( level . equals ( "ADMIN" ) ) { modelLevel = Staff . Level . ADMIN ; } if ( ! ID . isValidId ( id ) ) { throw new IllegalValueException ( ID . MESSAGE_CONSTRAINTS ) ; } final ID modelID = new ID ( id ) ; if ( phone == null ) { throw new IllegalValueException ( String . format ( MISSING_FIELD_MESSAGE_FORMAT , Phone . class . getSimpleName ( ) ) ) ; } if ( ! Phone . isValidPhone ( phone ) ) { throw new IllegalValueException ( Phone . MESSAGE_CONSTRAINTS ) ; } final Phone modelPhone = new Phone ( phone ) ; if ( email == null ) { throw new IllegalValueException ( String . format ( MISSING_FIELD_MESSAGE_FORMAT , Email . class . getSimpleName ( ) ) ) ; } if ( ! Email . isValidEmail ( email ) ) { throw new IllegalValueException ( Email . MESSAGE_CONSTRAINTS ) ; } final Email modelEmail = new Email ( email ) ; if ( ! Salary . isValidSalary ( salary ) ) { throw new IllegalValueException ( Salary . MESSAGE_CONSTRAINTS ) ; } final Salary modelSalary = new Salary ( salary ) ; if ( address == null ) { throw new IllegalValueException ( String . format ( MISSING_FIELD_MESSAGE_FORMAT , Address . class . getSimpleName ( ) ) ) ; } if ( ! Address . isValidAddress ( address ) ) { throw new IllegalValueException ( Address . MESSAGE_CONSTRAINTS ) ; } final Address modelAddress = new Address ( address ) ; return new Staff ( modelName , modelID , modelGender , modelLevel , modelPhone , modelEmail , modelSalary , modelAddress , modelAssignedCoursesID , modelTags ) ; }
Converts this Jackson-friendly adapted staff object into the model's {@code Staff} object.
Converts this Jackson - friendly adapted staff object into the model ' s { @code Staff } object .