forked from nus-cs2103-AY2223S1/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 #171 from AY2223S1-CS2103T-W13-4/jingyan/team-fix
Team Fix
- Loading branch information
Showing
16 changed files
with
288 additions
and
83 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
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
19 changes: 19 additions & 0 deletions
19
src/main/java/seedu/address/logic/parser/DescriptionConverter.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,19 @@ | ||
package seedu.address.logic.parser; | ||
|
||
import picocli.CommandLine; | ||
import seedu.address.logic.parser.exceptions.ParseException; | ||
import seedu.address.model.team.Description; | ||
|
||
/** | ||
* Converter from {@code String} to {@code Description} | ||
*/ | ||
public class DescriptionConverter implements CommandLine.ITypeConverter<Description> { | ||
@Override | ||
public Description convert(String value) throws Exception { | ||
try { | ||
return ParserUtil.parseDescription(value); | ||
} catch (ParseException e) { | ||
throw new CommandLine.TypeConversionException(e.getMessage()); | ||
} | ||
} | ||
} |
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
19 changes: 19 additions & 0 deletions
19
src/main/java/seedu/address/logic/parser/TeamNameConverter.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,19 @@ | ||
package seedu.address.logic.parser; | ||
|
||
import picocli.CommandLine; | ||
import seedu.address.logic.parser.exceptions.ParseException; | ||
import seedu.address.model.team.TeamName; | ||
|
||
/** | ||
* Converter from {@code String} to {@code TeamName} | ||
*/ | ||
public class TeamNameConverter implements CommandLine.ITypeConverter<TeamName> { | ||
@Override | ||
public TeamName convert(String value) throws Exception { | ||
try { | ||
return ParserUtil.parseTeamName(value); | ||
} catch (ParseException e) { | ||
throw new CommandLine.TypeConversionException(e.getMessage()); | ||
} | ||
} | ||
} |
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,56 @@ | ||
package seedu.address.model.team; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
import static seedu.address.commons.util.AppUtil.checkArgument; | ||
|
||
/** | ||
* Represents a Team's description in the addressbook | ||
* Guarantees: immutable; is valid as declared in {@link #isValidTeamDescription(String)} | ||
*/ | ||
public class Description { | ||
|
||
public static final String MESSAGE_CONSTRAINTS = | ||
"Team description should only contain alphanumeric characters and spaces, and it should not be blank"; | ||
|
||
public static final String VALIDATION_REGEX = "[\\p{Alnum}][\\p{Alnum} ]*"; | ||
public static final String NO_DESCRIPTION_STRING = "No description added"; | ||
public static final Description NO_DESCRIPTION = new Description(NO_DESCRIPTION_STRING); | ||
public static final Description DEFAULT_DESCRIPTION = new Description("A default team created just for you"); | ||
public final String description; | ||
|
||
/** | ||
* Constructs a {@code Description} | ||
* | ||
* @param description A valid description. | ||
*/ | ||
public Description(String description) { | ||
requireNonNull(description); | ||
checkArgument(isValidTeamDescription(description), MESSAGE_CONSTRAINTS); | ||
this.description = description; | ||
} | ||
|
||
/** | ||
* Returns true if a given string is a valid description. | ||
*/ | ||
public static boolean isValidTeamDescription(String test) { | ||
return test.matches(VALIDATION_REGEX); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return description; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object other) { | ||
return other == this // short circuit if same object | ||
|| (other instanceof Description // instanceof handles nulls | ||
&& description.equals(((Description) other).description)); // state check | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return description.hashCode(); | ||
} | ||
|
||
} |
Oops, something went wrong.