Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/ryanguai/tp
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanguai committed Oct 9, 2022
2 parents c9a11b1 + ad509d8 commit 3b749f9
Show file tree
Hide file tree
Showing 42 changed files with 504 additions and 138 deletions.
5 changes: 5 additions & 0 deletions src/main/java/seedu/address/logic/commands/HelpCommand.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package seedu.address.logic.commands;

import seedu.address.logic.commands.contact.AddContactCommand;
import seedu.address.logic.commands.contact.DeleteContactCommand;
import seedu.address.logic.commands.contact.EditContactCommand;
import seedu.address.logic.commands.contact.FindContactCommand;
import seedu.address.logic.commands.contact.ListContactCommand;
import seedu.address.model.Model;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package seedu.address.logic.commands;
package seedu.address.logic.commands.contact;

import static java.util.Objects.requireNonNull;
import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS;
Expand All @@ -7,6 +7,8 @@
import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE;
import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG;

import seedu.address.logic.commands.Command;
import seedu.address.logic.commands.CommandResult;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.Model;
import seedu.address.model.person.Person;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package seedu.address.logic.commands;
package seedu.address.logic.commands.contact;

import static java.util.Objects.requireNonNull;

import java.util.List;

import seedu.address.commons.core.Messages;
import seedu.address.commons.core.index.Index;
import seedu.address.logic.commands.Command;
import seedu.address.logic.commands.CommandResult;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.Model;
import seedu.address.model.person.Person;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package seedu.address.logic.commands;
package seedu.address.logic.commands.contact;

import static java.util.Objects.requireNonNull;
import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS;
Expand All @@ -17,6 +17,8 @@
import seedu.address.commons.core.Messages;
import seedu.address.commons.core.index.Index;
import seedu.address.commons.util.CollectionUtil;
import seedu.address.logic.commands.Command;
import seedu.address.logic.commands.CommandResult;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.Model;
import seedu.address.model.person.Address;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package seedu.address.logic.commands;
package seedu.address.logic.commands.contact;

import static java.util.Objects.requireNonNull;

import seedu.address.commons.core.Messages;
import seedu.address.logic.commands.Command;
import seedu.address.logic.commands.CommandResult;
import seedu.address.model.Model;
import seedu.address.model.person.NameContainsKeywordsPredicate;
import seedu.address.model.person.PersonContainsKeywordsPredicate;

/**
* Finds and lists all persons in address book whose name contains any of the argument keywords.
Expand All @@ -19,9 +21,9 @@ public class FindContactCommand extends Command {
+ "Parameters: KEYWORD [MORE_KEYWORDS]...\n"
+ "Example: " + COMMAND_WORD + " alice bob charlie";

private final NameContainsKeywordsPredicate predicate;
private final PersonContainsKeywordsPredicate predicate;

public FindContactCommand(NameContainsKeywordsPredicate predicate) {
public FindContactCommand(PersonContainsKeywordsPredicate predicate) {
this.predicate = predicate;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package seedu.address.logic.commands;
package seedu.address.logic.commands.contact;

import static java.util.Objects.requireNonNull;
import static seedu.address.model.Model.PREDICATE_SHOW_ALL_PERSONS;

import seedu.address.logic.commands.Command;
import seedu.address.logic.commands.CommandResult;
import seedu.address.model.Model;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package seedu.address.logic.commands;
package seedu.address.logic.commands.tag;

import static java.util.Objects.requireNonNull;
import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG;
Expand All @@ -13,6 +13,8 @@
import seedu.address.commons.core.Messages;
import seedu.address.commons.core.index.Index;
import seedu.address.commons.util.CollectionUtil;
import seedu.address.logic.commands.Command;
import seedu.address.logic.commands.CommandResult;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.Model;
import seedu.address.model.person.Address;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package seedu.address.logic.commands;
package seedu.address.logic.commands.tag;

import static java.util.Objects.requireNonNull;
import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG;
Expand All @@ -13,6 +13,8 @@
import seedu.address.commons.core.Messages;
import seedu.address.commons.core.index.Index;
import seedu.address.commons.util.CollectionUtil;
import seedu.address.logic.commands.Command;
import seedu.address.logic.commands.CommandResult;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.Model;
import seedu.address.model.person.Address;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package seedu.address.logic.commands;
package seedu.address.logic.commands.task;

import static java.util.Objects.requireNonNull;
import static seedu.address.logic.parser.CliSyntax.PREFIX_TASK_DEADLINE;
import static seedu.address.logic.parser.CliSyntax.PREFIX_TASK_DESCRIPTION;

import seedu.address.logic.commands.Command;
import seedu.address.logic.commands.CommandResult;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.Model;
import seedu.address.model.task.Task;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package seedu.address.logic.commands;
package seedu.address.logic.commands.task;

import static java.util.Objects.requireNonNull;
import static seedu.address.model.Model.PREDICATE_SHOW_ALL_TASKS;

import seedu.address.logic.commands.Command;
import seedu.address.logic.commands.CommandResult;
import seedu.address.model.Model;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package seedu.address.logic.commands;
package seedu.address.logic.commands.task;

import static java.util.Objects.requireNonNull;

import java.util.List;

import seedu.address.commons.core.Messages;
import seedu.address.commons.core.index.Index;
import seedu.address.logic.commands.Command;
import seedu.address.logic.commands.CommandResult;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.Model;
import seedu.address.model.task.Task;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package seedu.address.logic.commands;
package seedu.address.logic.commands.task;

import static java.util.Objects.requireNonNull;

import java.util.List;

import seedu.address.commons.core.Messages;
import seedu.address.commons.core.index.Index;
import seedu.address.logic.commands.Command;
import seedu.address.logic.commands.CommandResult;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.Model;
import seedu.address.model.task.Task;
Expand Down
28 changes: 18 additions & 10 deletions src/main/java/seedu/address/logic/parser/AddressBookParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,29 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import seedu.address.logic.commands.AddContactCommand;
import seedu.address.logic.commands.AddTagCommand;
import seedu.address.logic.commands.ClearCommand;
import seedu.address.logic.commands.Command;
import seedu.address.logic.commands.DeleteContactCommand;
import seedu.address.logic.commands.DeleteTagCommand;
import seedu.address.logic.commands.EditContactCommand;
import seedu.address.logic.commands.ExitCommand;
import seedu.address.logic.commands.FindContactCommand;
import seedu.address.logic.commands.HelpCommand;
import seedu.address.logic.commands.ListContactCommand;
import seedu.address.logic.commands.ListTaskCommand;
import seedu.address.logic.commands.MarkTaskCommand;
import seedu.address.logic.commands.UnmarkTaskCommand;
import seedu.address.logic.commands.contact.AddContactCommand;
import seedu.address.logic.commands.contact.DeleteContactCommand;
import seedu.address.logic.commands.contact.EditContactCommand;
import seedu.address.logic.commands.contact.FindContactCommand;
import seedu.address.logic.commands.contact.ListContactCommand;
import seedu.address.logic.commands.tag.AddTagCommand;
import seedu.address.logic.commands.tag.DeleteTagCommand;
import seedu.address.logic.commands.task.ListTaskCommand;
import seedu.address.logic.commands.task.MarkTaskCommand;
import seedu.address.logic.commands.task.UnmarkTaskCommand;
import seedu.address.logic.parser.contact.AddContactCommandParser;
import seedu.address.logic.parser.contact.DeleteContactCommandParser;
import seedu.address.logic.parser.contact.EditContactCommandParser;
import seedu.address.logic.parser.contact.FindContactCommandParser;
import seedu.address.logic.parser.exceptions.ParseException;
import seedu.address.logic.parser.tag.AddTagCommandParser;
import seedu.address.logic.parser.tag.DeleteTagCommandParser;
import seedu.address.logic.parser.task.MarkTaskCommandParser;
import seedu.address.logic.parser.task.UnmarkTaskCommandParser;

/**
* Parses user input.
Expand Down

This file was deleted.

82 changes: 82 additions & 0 deletions src/main/java/seedu/address/logic/parser/ParserUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import static java.util.Objects.requireNonNull;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import seedu.address.commons.core.index.Index;
Expand Down Expand Up @@ -51,6 +53,26 @@ public static Name parseName(String name) throws ParseException {
return new Name(trimmedName);
}

/**
* Parses a string of {@code String names} into a list of {@code String names}.
* Leading and trailing whitespaces will be trimmed.
*
* @throws ParseException if any {@code name} is invalid.
*/
public static List<Name> parseNames(String names) throws ParseException {
requireNonNull(names);
String trimmedNames = names.trim();
String[] nameArr = trimmedNames.split(" ");
ArrayList<Name> nameList = new ArrayList<>();
for (String name : nameArr) {
if (!Name.isValidName(name)) {
throw new ParseException(Name.MESSAGE_CONSTRAINTS);
}
nameList.add(new Name(name));
}
return nameList;
}

/**
* Parses a {@code String phone} into a {@code Phone}.
* Leading and trailing whitespaces will be trimmed.
Expand All @@ -66,6 +88,26 @@ public static Phone parsePhone(String phone) throws ParseException {
return new Phone(trimmedPhone);
}

/**
* Parses a string of {@code String phones} into a list of {@code String phones}.
* Leading and trailing whitespaces will be trimmed.
*
* @throws ParseException if any {@code phone} is invalid.
*/
public static List<Phone> parsePhones(String phones) throws ParseException {
requireNonNull(phones);
String trimmedNames = phones.trim();
String[] phoneArr = trimmedNames.split(" ");
ArrayList<Phone> phoneList = new ArrayList<>();
for (String phone : phoneArr) {
if (!Phone.isValidPhone(phone)) {
throw new ParseException(Phone.MESSAGE_CONSTRAINTS);
}
phoneList.add(new Phone(phone));
}
return phoneList;
}

/**
* Parses a {@code String address} into an {@code Address}.
* Leading and trailing whitespaces will be trimmed.
Expand All @@ -81,6 +123,26 @@ public static Address parseAddress(String address) throws ParseException {
return new Address(trimmedAddress);
}

/**
* Parses a string of {@code String addresses} into a list of {@code String addresses}.
* Leading and trailing whitespaces will be trimmed.
*
* @throws ParseException if any {@code address} is invalid.
*/
public static List<Address> parseAddresses(String addresses) throws ParseException {
requireNonNull(addresses);
String trimmedNames = addresses.trim();
String[] addressArr = trimmedNames.split(" ");
ArrayList<Address> addressList = new ArrayList<>();
for (String address : addressArr) {
if (!Address.isValidAddress(address)) {
throw new ParseException(Address.MESSAGE_CONSTRAINTS);
}
addressList.add(new Address(address));
}
return addressList;
}

/**
* Parses a {@code String email} into an {@code Email}.
* Leading and trailing whitespaces will be trimmed.
Expand All @@ -96,6 +158,26 @@ public static Email parseEmail(String email) throws ParseException {
return new Email(trimmedEmail);
}

/**
* Parses a string of {@code String emails} into a list of {@code String emails}.
* Leading and trailing whitespaces will be trimmed.
*
* @throws ParseException if any {@code email} is invalid.
*/
public static List<Email> parseEmails(String emails) throws ParseException {
requireNonNull(emails);
String trimmedNames = emails.trim();
String[] emailArr = trimmedNames.split(" ");
ArrayList<Email> emailList = new ArrayList<>();
for (String email : emailArr) {
if (!Email.isValidEmail(email)) {
throw new ParseException(Email.MESSAGE_CONSTRAINTS);
}
emailList.add(new Email(email));
}
return emailList;
}

/**
* Parses a {@code String tag} into a {@code Tag}.
* Leading and trailing whitespaces will be trimmed.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package seedu.address.logic.parser;
package seedu.address.logic.parser.contact;

import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT;
import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS;
Expand All @@ -10,7 +10,12 @@
import java.util.Set;
import java.util.stream.Stream;

import seedu.address.logic.commands.AddContactCommand;
import seedu.address.logic.commands.contact.AddContactCommand;
import seedu.address.logic.parser.ArgumentMultimap;
import seedu.address.logic.parser.ArgumentTokenizer;
import seedu.address.logic.parser.Parser;
import seedu.address.logic.parser.ParserUtil;
import seedu.address.logic.parser.Prefix;
import seedu.address.logic.parser.exceptions.ParseException;
import seedu.address.model.person.Address;
import seedu.address.model.person.Email;
Expand Down
Loading

0 comments on commit 3b749f9

Please sign in to comment.