forked from nus-cs2103-AY2324S2/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 #34 from ashleyy2444/branch-addProgrammingLanguages
Branch add programming languages
- Loading branch information
Showing
30 changed files
with
545 additions
and
58 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 |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
import static seedu.address.logic.parser.CliSyntax.PREFIX_INTERVIEWTIME; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_PROGRAMMING_LANGUAGE; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_SALARY; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; | ||
import static seedu.address.model.Model.PREDICATE_SHOW_ALL_PERSONS; | ||
|
@@ -25,6 +26,7 @@ | |
import seedu.address.logic.Messages; | ||
import seedu.address.logic.commands.exceptions.CommandException; | ||
import seedu.address.model.Model; | ||
import seedu.address.model.language.ProgrammingLanguage; | ||
import seedu.address.model.person.Address; | ||
import seedu.address.model.person.CompanyName; | ||
import seedu.address.model.person.Email; | ||
|
@@ -56,6 +58,7 @@ public class EditCommand extends Command { | |
+ "[" + PREFIX_SALARY + "SALARY] " | ||
+ "[" + PREFIX_INFO + "INFO] " | ||
+ "[" + PREFIX_TAG + "TAG]...\n" | ||
+ "[" + PREFIX_PROGRAMMING_LANGUAGE + "PROGRAMMING-LANGUAGE]...\n" | ||
+ "Example: " + COMMAND_WORD + " 1 " | ||
+ PREFIX_PHONE + "91234567 " | ||
+ PREFIX_EMAIL + "[email protected]"; | ||
|
@@ -115,10 +118,12 @@ private static Person createEditedPerson(Person personToEdit, EditPersonDescript | |
Salary updatedSalary = editPersonDescriptor.getSalary().orElse(personToEdit.getSalary()); | ||
Info updatedInfo = editPersonDescriptor.getInfo().orElse(personToEdit.getInfo()); | ||
Set<Tag> updatedTags = editPersonDescriptor.getTags().orElse(personToEdit.getTags()); | ||
Set<ProgrammingLanguage> updatedProgrammingLanguages = editPersonDescriptor.getProgrammingLanguages() | ||
.orElse(personToEdit.getProgrammingLanguages()); | ||
|
||
return new Person( | ||
updatedCompanyName, updatedName, updatedPhone, updatedEmail, | ||
updatedAddress, updatedDateTime, updatedSalary, updatedInfo, updatedTags); | ||
updatedAddress, updatedDateTime, updatedSalary, updatedInfo, updatedTags, updatedProgrammingLanguages); | ||
} | ||
|
||
@Override | ||
|
@@ -159,6 +164,7 @@ public static class EditPersonDescriptor { | |
private Salary salary; | ||
private Info info; | ||
private Set<Tag> tags; | ||
private Set<ProgrammingLanguage> programmingLanguages; | ||
|
||
public EditPersonDescriptor() {} | ||
|
||
|
@@ -176,13 +182,15 @@ public EditPersonDescriptor(EditPersonDescriptor toCopy) { | |
setSalary(toCopy.salary); | ||
setInfo(toCopy.info); | ||
setTags(toCopy.tags); | ||
setProgrammingLanguages(toCopy.programmingLanguages); | ||
} | ||
|
||
/** | ||
* Returns true if at least one field is edited. | ||
*/ | ||
public boolean isAnyFieldEdited() { | ||
return CollectionUtil.isAnyNonNull(name, phone, email, address, dateTime, salary, info, tags); | ||
return CollectionUtil.isAnyNonNull(name, phone, email, address, dateTime, salary, info, tags, | ||
programmingLanguages); | ||
} | ||
public void setCompanyName(CompanyName companyName) { | ||
this.companyName = companyName; | ||
|
@@ -261,6 +269,24 @@ public Optional<Set<Tag>> getTags() { | |
return (tags != null) ? Optional.of(Collections.unmodifiableSet(tags)) : Optional.empty(); | ||
} | ||
|
||
/** | ||
* Sets {@code programmingLanguages} to this object's {@code programmingLanguages}. | ||
* A defensive copy of {@code programmingLanguages} is used internally. | ||
*/ | ||
public void setProgrammingLanguages(Set<ProgrammingLanguage> programmingLanguages) { | ||
this.programmingLanguages = (programmingLanguages != null) ? new HashSet<>(programmingLanguages) : null; | ||
} | ||
|
||
/** | ||
* Returns an unmodifiable programmingLanguages set, which throws {@code UnsupportedOperationException} | ||
* if modification is attempted. | ||
* Returns {@code Optional#empty()} if {@code programmingLanguages} is null. | ||
*/ | ||
public Optional<Set<ProgrammingLanguage>> getProgrammingLanguages() { | ||
return (programmingLanguages != null) ? Optional.of(Collections | ||
.unmodifiableSet(programmingLanguages)) : Optional.empty(); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object other) { | ||
if (other == this) { | ||
|
@@ -281,7 +307,8 @@ public boolean equals(Object other) { | |
&& Objects.equals(dateTime, otherEditPersonDescriptor.dateTime) | ||
&& Objects.equals(salary, otherEditPersonDescriptor.salary) | ||
&& Objects.equals(info, otherEditPersonDescriptor.info) | ||
&& Objects.equals(tags, otherEditPersonDescriptor.tags); | ||
&& Objects.equals(tags, otherEditPersonDescriptor.tags) | ||
&& Objects.equals(programmingLanguages, otherEditPersonDescriptor.programmingLanguages); | ||
} | ||
|
||
@Override | ||
|
@@ -296,6 +323,7 @@ public String toString() { | |
.add("salary", salary) | ||
.add("info", info) | ||
.add("tags", tags) | ||
.add("programmingLanguages", programmingLanguages) | ||
.toString(); | ||
} | ||
|
||
|
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
68 changes: 68 additions & 0 deletions
68
src/main/java/seedu/address/model/language/ProgrammingLanguage.java
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,68 @@ | ||
package seedu.address.model.language; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
import static seedu.address.commons.util.AppUtil.checkArgument; | ||
|
||
/** | ||
* Represents a Programming Language in the address book. | ||
* Guarantees: immutable; name is valid as declared in {@link #isValidLanguageName(String)} | ||
*/ | ||
public class ProgrammingLanguage { | ||
|
||
public static final String MESSAGE_CONSTRAINTS = | ||
"Programming Languages should be alphanumeric and may contain some special characters (+ and #)" | ||
+ ", and must be less than 50 characters"; | ||
public static final String VALIDATION_REGEX = "[\\p{Alnum}+#\\s]{1,50}"; | ||
public final String languageName; | ||
|
||
/** | ||
* Constructs a {@code ProgrammingLanguage}. | ||
* | ||
* @param languageName A valid programming language name. | ||
*/ | ||
public ProgrammingLanguage(String languageName) { | ||
requireNonNull(languageName); | ||
checkArgument(isValidLanguageName(languageName), MESSAGE_CONSTRAINTS); | ||
this.languageName = languageName; | ||
} | ||
|
||
/** | ||
* Returns true if a given string is a valid programming language name. | ||
* | ||
* @param test The string to test for validity. | ||
* @return {@code true} if the string is a valid programming language name, {@code false} otherwise. | ||
*/ | ||
public static boolean isValidLanguageName(String test) { | ||
return test.matches(VALIDATION_REGEX); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object other) { | ||
if (other == this) { | ||
return true; | ||
} | ||
|
||
// instanceof handles nulls | ||
if (!(other instanceof ProgrammingLanguage)) { | ||
return false; | ||
} | ||
|
||
ProgrammingLanguage otherLanguage = (ProgrammingLanguage) other; | ||
return languageName.equals(otherLanguage.languageName); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return languageName.hashCode(); | ||
} | ||
|
||
/** | ||
* Returns the string representation of this programming language. | ||
* | ||
* @return The string representation of this programming language. | ||
*/ | ||
@Override | ||
public String toString() { | ||
return "[Programming Language: " + languageName + "]"; | ||
} | ||
} |
Oops, something went wrong.