forked from nus-cs2103-AY2324S1/tp
-
Notifications
You must be signed in to change notification settings - Fork 0
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 nus-cs2103-AY2324S1#82 from jx124/extract-client-l…
…ead-tags Extract "client" and "lead" tags into Type class
- Loading branch information
Showing
15 changed files
with
231 additions
and
42 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
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 type in the address book. | ||
* Guarantees: immutable; is valid as declared in {@link #isValidType(String)} | ||
*/ | ||
public class Type { | ||
|
||
public static final String MESSAGE_CONSTRAINTS = "Types can only be 'client' or 'lead'"; | ||
|
||
public static final String VALIDATION_REGEX = "client|lead"; | ||
|
||
public final String value; | ||
|
||
/** | ||
* Constructs a {@code Type}. | ||
* | ||
* @param type A valid type. | ||
*/ | ||
public Type(String type) { | ||
requireNonNull(type); | ||
checkArgument(isValidType(type), MESSAGE_CONSTRAINTS); | ||
value = type; | ||
} | ||
|
||
/** | ||
* Returns true if a given string is a valid type. | ||
*/ | ||
public static boolean isValidType(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 Type)) { | ||
return false; | ||
} | ||
|
||
Type otherType = (Type) other; | ||
return value.equals(otherType.value); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return value.hashCode(); | ||
} | ||
|
||
} |
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 |
---|---|---|
|
@@ -3,12 +3,14 @@ | |
"name": "Alice Pauline", | ||
"phone": "94351253", | ||
"email": "[email protected]", | ||
"type": "lead", | ||
"address": "123, Jurong West Ave 6, #08-111", | ||
"tags": [ "Client", "friends" ] | ||
}, { | ||
"name": "Alice Pauline", | ||
"phone": "94351253", | ||
"email": "[email protected]", | ||
"type": "lead", | ||
"address": "4th street", | ||
"tags": [ "Client" ] | ||
} ] | ||
|
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 |
---|---|---|
|
@@ -4,43 +4,50 @@ | |
"name" : "Alice Pauline", | ||
"phone" : "94351253", | ||
"email" : "[email protected]", | ||
"type": "client", | ||
"address" : "123, Jurong West Ave 6, #08-111", | ||
"tags" : [ "Client", "friends" ] | ||
"tags" : [ "friends" ] | ||
}, { | ||
"name" : "Benson Meier", | ||
"phone" : "98765432", | ||
"email" : "[email protected]", | ||
"type": "client", | ||
"address" : "311, Clementi Ave 2, #02-25", | ||
"tags" : [ "Client", "owesMoney", "friends" ] | ||
"tags" : [ "owesMoney", "friends" ] | ||
}, { | ||
"name" : "Carl Kurz", | ||
"phone" : "95352563", | ||
"email" : "[email protected]", | ||
"type": "client", | ||
"address" : "wall street", | ||
"tags" : [ "Client" ] | ||
"tags" : [] | ||
}, { | ||
"name" : "Daniel Meier", | ||
"phone" : "87652533", | ||
"email" : "[email protected]", | ||
"type": "client", | ||
"address" : "10th street", | ||
"tags" : [ "Client", "friends" ] | ||
"tags" : [ "friends" ] | ||
}, { | ||
"name" : "Elle Meyer", | ||
"phone" : "9482224", | ||
"email" : "[email protected]", | ||
"type": "lead", | ||
"address" : "michegan ave", | ||
"tags" : [ "Lead" ] | ||
"tags" : [] | ||
}, { | ||
"name" : "Fiona Kunz", | ||
"phone" : "9482427", | ||
"email" : "[email protected]", | ||
"type": "lead", | ||
"address" : "little tokyo", | ||
"tags" : [ "Lead" ] | ||
"tags" : [] | ||
}, { | ||
"name" : "George Best", | ||
"phone" : "9482442", | ||
"email" : "[email protected]", | ||
"type": "lead", | ||
"address" : "4th street", | ||
"tags" : [ "Lead" ] | ||
"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
Oops, something went wrong.