forked from nus-cs2103-AY1617S1/addressbook-level4
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Command.java
62 lines (53 loc) · 1.79 KB
/
Command.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package seedu.agendum.logic.commands;
import seedu.agendum.commons.core.EventsCenter;
import seedu.agendum.commons.core.Messages;
import seedu.agendum.commons.events.ui.IncorrectCommandAttemptedEvent;
import seedu.agendum.model.Model;
/**
* Represents a command with hidden internal logic and the ability to be executed.
*/
public abstract class Command {
protected Model model;
/**
* Return the name of this command.
*/
public abstract String getName();
/**
* Return the format of this command.
*/
public abstract String getFormat();
/**
* Return the description of this command.
*/
public abstract String getDescription();
public Command() {};
/**
* Constructs a feedback message to summarise an operation that displayed a listing of tasks.
*
* @param displaySize used to generate summary
* @return summary message for tasks displayed
*/
public static String getMessageForTaskListShownSummary(int displaySize) {
return String.format(Messages.MESSAGE_TASKS_LISTED_OVERVIEW, displaySize);
}
/**
* Executes the command and returns the result message.
*
* @return feedback message of the operation result for display
*/
public abstract CommandResult execute();
/**
* Provides any needed dependencies to the command.
* Commands making use of any of these should override this method to gain
* access to the dependencies.
*/
public void setData(Model model) {
this.model = model;
}
/**
* Raises an event to indicate an attempt to execute an incorrect command
*/
protected void indicateAttemptToExecuteIncorrectCommand() {
EventsCenter.getInstance().post(new IncorrectCommandAttemptedEvent(this));
}
}