forked from nus-cs2103-AY2425S1/tp
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #49 from thisisaditya17/feature/add-skills
Create a field in add command (Skill Sets)
- Loading branch information
Showing
32 changed files
with
429 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_NOTE; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_SKILLS; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_STATUS; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; | ||
import static seedu.address.model.Model.PREDICATE_SHOW_ALL_PERSONS; | ||
|
@@ -29,6 +30,7 @@ | |
import seedu.address.model.person.Note; | ||
import seedu.address.model.person.Person; | ||
import seedu.address.model.person.Phone; | ||
import seedu.address.model.person.Skills; | ||
import seedu.address.model.person.Status; | ||
import seedu.address.model.tag.Tag; | ||
|
||
|
@@ -47,12 +49,17 @@ public class EditCommand extends Command { | |
+ "[" + PREFIX_PHONE + "PHONE] " | ||
+ "[" + PREFIX_EMAIL + "EMAIL] " | ||
+ "[" + PREFIX_ADDRESS + "ADDRESS] " | ||
+ "[" + PREFIX_SKILLS + "SKILLS] " | ||
+ "[" + PREFIX_STATUS + "STATUS]" | ||
+ "[" + PREFIX_NOTE + "NOTE] " | ||
+ "[" + PREFIX_TAG + "TAG]...\n" | ||
+ "Example: " + COMMAND_WORD + " 1 " | ||
+ PREFIX_PHONE + "91234567 " | ||
+ PREFIX_EMAIL + "[email protected]"; | ||
+ PREFIX_EMAIL + "[email protected]" | ||
+ PREFIX_ADDRESS + "311, Clementi Ave 2, #02-25 " | ||
+ PREFIX_SKILLS + "java, python " | ||
+ PREFIX_TAG + "friends"; | ||
|
||
|
||
public static final String MESSAGE_EDIT_PERSON_SUCCESS = "Edited Person: %1$s"; | ||
public static final String MESSAGE_NOT_EDITED = "At least one field to edit must be provided."; | ||
|
@@ -105,11 +112,12 @@ private static Person createEditedPerson(Person personToEdit, EditPersonDescript | |
Phone updatedPhone = editPersonDescriptor.getPhone().orElse(personToEdit.getPhone()); | ||
Email updatedEmail = editPersonDescriptor.getEmail().orElse(personToEdit.getEmail()); | ||
Address updatedAddress = editPersonDescriptor.getAddress().orElse(personToEdit.getAddress()); | ||
Skills updatedSkills = editPersonDescriptor.getSkills().orElse(personToEdit.getSkills()); | ||
Status updatedStatus = editPersonDescriptor.getStatus().orElse(personToEdit.getStatus()); | ||
Set<Tag> updatedTags = editPersonDescriptor.getTags().orElse(personToEdit.getTags()); | ||
Note updatedNote = editPersonDescriptor.getNote().orElse(personToEdit.getNote()); | ||
|
||
return new Person(updatedName, updatedPhone, updatedEmail, updatedAddress, | ||
return new Person(updatedName, updatedPhone, updatedEmail, updatedAddress, updatedSkills, | ||
updatedStatus, updatedNote, updatedTags); | ||
} | ||
|
||
|
@@ -146,6 +154,7 @@ public static class EditPersonDescriptor { | |
private Phone phone; | ||
private Email email; | ||
private Address address; | ||
private Skills skills; | ||
private Status status; | ||
private Note note; | ||
private Set<Tag> tags; | ||
|
@@ -161,6 +170,7 @@ public EditPersonDescriptor(EditPersonDescriptor toCopy) { | |
setPhone(toCopy.phone); | ||
setEmail(toCopy.email); | ||
setAddress(toCopy.address); | ||
setSkills(toCopy.skills); | ||
setStatus(toCopy.status); | ||
setNote(toCopy.note); | ||
setTags(toCopy.tags); | ||
|
@@ -205,6 +215,14 @@ public Optional<Address> getAddress() { | |
return Optional.ofNullable(address); | ||
} | ||
|
||
public void setSkills(Skills skills) { | ||
this.skills = skills; | ||
} | ||
|
||
public Optional<Skills> getSkills() { | ||
return Optional.ofNullable(skills); | ||
} | ||
|
||
public void setStatus(Status status) { | ||
this.status = status; | ||
} | ||
|
@@ -254,6 +272,7 @@ public boolean equals(Object other) { | |
&& Objects.equals(phone, otherEditPersonDescriptor.phone) | ||
&& Objects.equals(email, otherEditPersonDescriptor.email) | ||
&& Objects.equals(address, otherEditPersonDescriptor.address) | ||
&& Objects.equals(skills, otherEditPersonDescriptor.skills) | ||
&& Objects.equals(status, otherEditPersonDescriptor.status) | ||
&& Objects.equals(note, otherEditPersonDescriptor.note) | ||
&& Objects.equals(tags, otherEditPersonDescriptor.tags); | ||
|
@@ -266,6 +285,7 @@ public String toString() { | |
.add("phone", phone) | ||
.add("email", email) | ||
.add("address", address) | ||
.add("skills", tags) | ||
.add("status", status) | ||
.add("note", note) | ||
.add("tags", tags) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package seedu.address.model.person; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
import static seedu.address.commons.util.AppUtil.checkArgument; | ||
|
||
/** | ||
* Represents a Person's skills in the TalentSG | ||
* Guarantees: immutable; is valid as declared in {@link #isValidSkillsString(String)} | ||
*/ | ||
public class Skills { | ||
|
||
public static final String MESSAGE_CONSTRAINTS = | ||
"Skills should be a non-empty string consisting of alphabetic characters, separated by commas. " | ||
+ "Each skill should be between 1 and 30 characters long"; | ||
public static final String VALIDATION_REGEX = "^[a-zA-Z0-9+]+(, [a-zA-Z0-9+]+)*$"; | ||
public final String value; | ||
|
||
/** | ||
* Constructs a {@code Skills}. | ||
* | ||
* @param skills A valid skills string. | ||
*/ | ||
public Skills(String skills) { | ||
requireNonNull(skills); | ||
checkArgument(isValidSkillsString(skills), MESSAGE_CONSTRAINTS); | ||
value = skills; | ||
} | ||
|
||
/** | ||
* Returns true if a given string is a valid skill input. | ||
*/ | ||
public static boolean isValidSkillsString(String test) { | ||
return test.matches(VALIDATION_REGEX); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return value; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object other) { | ||
if (other == this) { | ||
return true; | ||
} | ||
|
||
// instanceof handles nulls | ||
if (!(other instanceof Skills)) { | ||
return false; | ||
} | ||
|
||
Skills otherSkills = (Skills) other; | ||
return value.equals(otherSkills.value); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return value.hashCode(); | ||
} | ||
|
||
} |
Oops, something went wrong.