Skip to content

Commit

Permalink
Merge pull request #210 from pjanthony2001/106-ug-ped
Browse files Browse the repository at this point in the history
Update JavaDocs
  • Loading branch information
Jolonauh authored Apr 15, 2024
2 parents 9f2a969 + 34555f2 commit 36900c9
Show file tree
Hide file tree
Showing 39 changed files with 103 additions and 78 deletions.
2 changes: 1 addition & 1 deletion src/main/java/seedu/address/MainApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ private Model initModelManager(Storage storage, ReadOnlyUserPrefs userPrefs) {
ReadOnlyCalendar initialCalendarData;
try {
calendarOptional = storage.readCalendar();
if (!calendarOptional.isPresent()) {
if (calendarOptional.isEmpty()) {
logger.info("Creating a new data file " + storage.getCalendarFilePath()
+ " populated with a sample Calendar.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
import seedu.address.history.exceptions.HistoryException;

/**
* @param <T> The type of state that the abstract class keeps track of
* @param <T> The type of state that the BufferedHistoryManager class keeps track of
*/
public class BufferedHistoryManager<T> extends HistoryManager<T> implements BufferedHistory<T> {

/**
* Constructs a new HistoryManager with a starting state.
* Constructs a new BufferedHistoryManager with a starting state. This state acts as the buffer.
*
* @param startState The initial state of the history.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/address/history/History.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public interface History<T> {
/**
* Rolls forward to the next state in the history.
*
* @throws Exception If there are no more future states to roll forward to.
* @throws HistoryException If there are no more future states to roll forward to.
*/
void rollForwardState() throws HistoryException;

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/seedu/address/history/HistoryManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import seedu.address.history.exceptions.HistoryException;

/**
* @param <T> The type of state that the abstract class keeps track of
* @param <T> The type of state that the HistoryManager class keeps track of
*/
public class HistoryManager<T> implements History<T> {
protected int currStateIdx;
Expand All @@ -23,7 +23,7 @@ public HistoryManager(T startState) {
}

/**
* Removes modelStates after the current state, effectively truncating the history.
* Removes states after the current state, effectively truncating the history.
*/
private void truncate() {
assert (currStateIdx >= 0 && currStateIdx < states.size());
Expand Down
23 changes: 14 additions & 9 deletions src/main/java/seedu/address/history/ModelState.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,21 @@

/**
* The `ModelState` class represents a snapshot of the ConnectCare application's state at a specific point in time.
* It contains information about the executed command and the list of tasks at that time.
* It contains information about the executed command, the AddressBook and the Calendar at that time.
*/
public class ModelState {
private final Command command;
private final ReadOnlyAddressBook addressBook;
private final Predicate<? super Person> filteredPersonsListPredicate;

private final ReadOnlyCalendar calendar;

/**
* Constructs a new ModelState object with the given command and task list.
*
* @param command The command executed to reach this state.
* @param addressBook The list of tasks at this state.
* @param addressBook The address book at this state.
* @param filteredPersonsListPredicate The predicate of the filtered list
* @param calendar
* @param calendar The calendar at this state
*/
public ModelState(Command command, ReadOnlyAddressBook addressBook,
Predicate<? super Person> filteredPersonsListPredicate, ReadOnlyCalendar calendar) {
Expand All @@ -38,9 +37,9 @@ public ModelState(Command command, ReadOnlyAddressBook addressBook,
}

/**
* Gets the list of tasks at this state.
* Gets the AddressBook at this state.
*
* @return The list of tasks.
* @return The AddressBook.
*/
public ReadOnlyAddressBook getAddressBook() {
return addressBook;
Expand All @@ -56,14 +55,19 @@ public Command getCommand() {
}

/**
* Gets the command executed to reach this state.
* Gets the predicate that was used at this state to display the filtered list of persons.
*
* @return The command.
* @return The predicate.
*/
public Predicate<? super Person> getFilteredPersonsListPredicate() {
return filteredPersonsListPredicate;
}

/**
* Gets the calendar at this state.
*
* @return The calendar.
*/
public ReadOnlyCalendar getCalendar() {
return calendar;
}
Expand All @@ -89,7 +93,8 @@ public boolean equals(Object other) {

return addressBook.equals(otherModelState.addressBook)
&& command.equals(otherModelState.command)
&& filteredList.equals(filteredListOther);
&& filteredList.equals(filteredListOther)
&& calendar.equals(otherModelState.calendar);

}
}
4 changes: 4 additions & 0 deletions src/main/java/seedu/address/logic/LogicManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,17 @@ public GuiSettings getGuiSettings() {
public void setGuiSettings(GuiSettings guiSettings) {
model.setGuiSettings(guiSettings);
}

@Override
public ObservableList<Event> getEventList() {
return model.getEventList();
}

@Override
public String retrievePreviousCommand() throws HistoryException {
return model.retrievePreviousCommand();
}

@Override
public String retrieveNextCommand() throws HistoryException {
return model.retrieveNextCommand();
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/seedu/address/logic/Messages.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public class Messages {
"Multiple values specified for the following single-valued field(s): ";
public static final String MESSAGE_DUPLICATE_NAMES = "There are people with the same names in the list";
public static final String MESSAGE_INVALID_EVENT_DISPLAYED_HEADING = "The event heading provided is invalid";
public static final String MESSAGE_DUPLICATE_HEADINGS = "There are events with the same headings in the list";



Expand Down Expand Up @@ -59,7 +58,7 @@ public static String format(Person person) {
return builder.toString();
}
/**
* Formats the {@code person} for display to the user.
* Formats the {@code event} for display to the user.
*/
public static String format(Event event) {
final StringBuilder builder = new StringBuilder();
Expand Down
26 changes: 22 additions & 4 deletions src/main/java/seedu/address/logic/commands/Command.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,39 @@
* Represents a command with hidden internal logic and the ability to be executed.
*/
public abstract class Command {
private boolean isReversible;
private boolean isReversible = false;

/**
* Executes the command and returns the result message.
*
* @param model {@code Model} which the command should operate on.
* @return feedback message of the operation result for display
* @return feedback message of the operation result for display.
* @throws CommandException If an error occurs during command execution.
*/
public abstract CommandResult execute(Model model) throws CommandException;

/**
* Returns the string representation of the command for History saving purposes.
*
* @return The string representation of command.
*/
public abstract String getCommandString();

/**
* Returns if the command is reversible or not. By default, it is not reversible.
*
* @return true if the command is reversible and false otherwise.
*/
public boolean isReversible() {
return isReversible;
}
public void setReversible(boolean setValue) {
isReversible = setValue;

/**
* Sets if the command is reversible or not. By default, it is not reversible.
*
* @param isReversible The boolean representing if the command is reversible or not.
*/
public void setReversible(boolean isReversible) {
this.isReversible = isReversible;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class CommandResult {

private final String feedbackToUser;
private final boolean isDisplayCommand;
private Person firstMatchedPerson;
private final Person firstMatchedPerson;

/** Help information should be shown to the user. */
private final boolean isShowHelp;
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/seedu/address/logic/commands/RedoCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@
import seedu.address.model.Model;

/**
* Undoes a command
* Redoes a command, reverting the model to that state
*/
public class RedoCommand extends Command {

public static final String COMMAND_WORD = "redo";

public static final String MESSAGE_USAGE = COMMAND_WORD + ": Redoes the most recent command.";
public static final String MESSAGE_SUCCESS = "Command redone: %1$s";
public static final String MESSAGE_NO_ROLLFORWARD = "There is no more history to roll forward!";
Expand Down
6 changes: 1 addition & 5 deletions src/main/java/seedu/address/logic/commands/StartCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import seedu.address.model.Model;

/**
* Start command for the start state
* A dummy start command for the start state
*/
public class StartCommand extends Command {

Expand All @@ -24,10 +24,6 @@ private StartCommand() {
public CommandResult execute(Model model) throws CommandException {
throw new CommandException(MESSAGE_SHOULD_NOT_EXECUTE);
}

/**
* @return String representation of command
*/
@Override
public String getCommandString() {
return COMMAND_WORD;
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/seedu/address/logic/commands/UndoCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@
import seedu.address.model.Model;

/**
* Undoes a command
* Undoes any command that is reversible, reverting the model to its previous state
*/
public class UndoCommand extends Command {

public static final String COMMAND_WORD = "undo";

public static final String MESSAGE_USAGE = COMMAND_WORD + ": Undoes the most recent command.";
public static final String MESSAGE_SUCCESS = "Command undone: %1$s";
public static final String MESSAGE_NO_ROLLBACK = "There is no more history to roll back!";
Expand Down
1 change: 1 addition & 0 deletions src/main/java/seedu/address/model/AddressBook.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ public int hashCode() {
return persons.hashCode();
}

@Override
public ReadOnlyAddressBook deepCopy() throws IllegalValueException {
return new JsonSerializableAddressBook(this).toModelType();
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/seedu/address/model/Calendar.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ public void resetData(ReadOnlyCalendar newData) {
setEvents(newData.getEventList());
}

//// person-level operations
//// event-level operations

/**
* Returns true if an event with the same identity as {@code even} exists in the calendar.
* Returns true if an event with the same "identity" (heading) as {@code event} exists in the calendar.
*/
public boolean hasEvent(Event event) {
requireNonNull(event);
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/seedu/address/model/ReadOnlyAddressBook.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,9 @@ public interface ReadOnlyAddressBook {
* This list will not contain any duplicate persons.
*/
ObservableList<Person> getPersonList();

/**
* Returns an unmodifiable deep copy of the ReadOnlyAddressBook
*/
ReadOnlyAddressBook deepCopy() throws IllegalValueException;
}
6 changes: 5 additions & 1 deletion src/main/java/seedu/address/model/ReadOnlyCalendar.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@
public interface ReadOnlyCalendar {
/**
* Returns an unmodifiable view of the event list.
* This list will not contain any duplicate events?.
* This list will not contain any duplicate events.
*/
ObservableList<Event> getEventList();

/**
* Returns an unmodifiable deep copy of the ReadOnlyCalendar.
*/
ReadOnlyCalendar deepCopy() throws IllegalValueException;
}
4 changes: 2 additions & 2 deletions src/main/java/seedu/address/model/event/Heading.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class Heading {
/**
* Constructs a {@code Heading}.
*
* @param heading A valid name.
* @param heading A valid heading for the event.
*/
public Heading(String heading) {
requireNonNull(heading);
Expand All @@ -32,7 +32,7 @@ public Heading(String heading) {
}

/**
* Returns true if a given string is a valid name.
* Returns true if a given string is a valid heading.
*/
public static boolean isValidHeading(String test) {
return (test.length() <= 70) && (test.matches(VALIDATION_REGEX));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
*/
public class DuplicateEventException extends RuntimeException {
public DuplicateEventException() {
super("Operation would result in duplicate persons");
super("Operation would result in duplicate events");
}
}
13 changes: 6 additions & 7 deletions src/main/java/seedu/address/storage/CalendarStorage.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
import java.util.Optional;

import seedu.address.commons.exceptions.DataLoadingException;
import seedu.address.model.ReadOnlyAddressBook;
import seedu.address.model.ReadOnlyCalendar;


/**
* Calendar Storage
* Represents a storage for the Calendar
*/
public interface CalendarStorage {
/**
Expand All @@ -19,7 +18,7 @@ public interface CalendarStorage {
Path getCalendarFilePath();

/**
* Returns AddressBook data as a {@link ReadOnlyAddressBook}.
* Returns Calander data as a {@link ReadOnlyCalendar}.
* Returns {@code Optional.empty()} if storage file is not found.
*
* @throws DataLoadingException if loading the data from storage failed.
Expand All @@ -32,15 +31,15 @@ public interface CalendarStorage {
Optional<ReadOnlyCalendar> readCalendar(Path filePath) throws DataLoadingException;

/**
* Saves the given {@link ReadOnlyAddressBook} to the storage.
* @param addressBook cannot be null.
* Saves the given {@link ReadOnlyCalendar} to the storage.
* @param calendar cannot be null.
* @throws IOException if there was any problem writing to the file.
*/
void saveCalendar(ReadOnlyCalendar addressBook) throws IOException;
void saveCalendar(ReadOnlyCalendar calendar) throws IOException;

/**
* @see #saveCalendar(ReadOnlyCalendar)
*/
void saveCalendar(ReadOnlyCalendar addressBook, Path filePath) throws IOException;
void saveCalendar(ReadOnlyCalendar calendar, Path filePath) throws IOException;

}
Loading

0 comments on commit 36900c9

Please sign in to comment.