forked from nus-cs2103-AY2324S1/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.
- Loading branch information
1 parent
97dd5a5
commit e354460
Showing
3 changed files
with
79 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package seedu.address.testutil; | ||
|
||
import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_GENDER; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_NRIC; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_REMARK; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; | ||
|
||
import java.util.Set; | ||
|
||
import seedu.address.logic.commands.AddDoctorCommand; | ||
import seedu.address.logic.commands.EditCommand.EditPersonDescriptor; | ||
import seedu.address.model.person.Doctor; | ||
import seedu.address.model.tag.Tag; | ||
|
||
/** | ||
* A utility class for Doctor. | ||
*/ | ||
public class DoctorUtil { | ||
|
||
/** | ||
* Returns an add command string for adding the {@code Doctor}. | ||
*/ | ||
public static String getAddDoctorCommand(Doctor doctor) { | ||
return AddDoctorCommand.COMMAND_WORD + " " + getDoctorDetails(doctor); | ||
} | ||
|
||
/** | ||
* Returns the part of command string for the given {@code person}'s details. | ||
*/ | ||
public static String getDoctorDetails(Doctor doctor) { | ||
StringBuilder sb = new StringBuilder(); | ||
sb.append(PREFIX_NAME + doctor.getName().fullName + " "); | ||
sb.append(PREFIX_PHONE + doctor.getPhone().value + " "); | ||
sb.append(PREFIX_EMAIL + doctor.getEmail().value + " "); | ||
sb.append(PREFIX_ADDRESS + doctor.getAddress().value + " "); | ||
sb.append(PREFIX_GENDER + doctor.getGender().value + " "); | ||
sb.append(PREFIX_NRIC + doctor.getIc().value + " "); | ||
doctor.getTags().stream().forEach( | ||
s -> sb.append(PREFIX_TAG + s.tagName + " ") | ||
); | ||
return sb.toString(); | ||
} | ||
|
||
/** | ||
* Returns the part of command string for the given {@code EditPersonDescriptor}'s details. | ||
*/ | ||
public static String getEditDoctorDescriptorDetails(EditPersonDescriptor descriptor) { | ||
StringBuilder sb = new StringBuilder(); | ||
descriptor.getName().ifPresent(name -> sb.append(PREFIX_NAME).append(name.fullName).append(" ")); | ||
descriptor.getPhone().ifPresent(phone -> sb.append(PREFIX_PHONE).append(phone.value).append(" ")); | ||
descriptor.getEmail().ifPresent(email -> sb.append(PREFIX_EMAIL).append(email.value).append(" ")); | ||
descriptor.getAddress().ifPresent(address -> sb.append(PREFIX_ADDRESS).append(address.value).append(" ")); | ||
descriptor.getRemark().ifPresent(remark -> sb.append(PREFIX_REMARK).append(remark.value).append(" ")); | ||
descriptor.getGender().ifPresent(gender -> sb.append(PREFIX_GENDER).append(gender.value).append(" ")); | ||
descriptor.getIc().ifPresent(ic -> sb.append(PREFIX_NRIC).append(ic.value).append(" ")); | ||
if (descriptor.getTags().isPresent()) { | ||
Set<Tag> tags = descriptor.getTags().get(); | ||
if (tags.isEmpty()) { | ||
sb.append(PREFIX_TAG); | ||
} else { | ||
tags.forEach(s -> sb.append(PREFIX_TAG).append(s.tagName).append(" ")); | ||
} | ||
} | ||
return sb.toString(); | ||
} | ||
} |