forked from nus-cs2103-AY2324S2/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 #72 from yisiox/63-refactor-parser-enum
Refactor Logic component to use enum factory pattern
- Loading branch information
Showing
50 changed files
with
755 additions
and
900 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
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
58 changes: 58 additions & 0 deletions
58
src/main/java/seedu/address/logic/commands/CommandType.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,58 @@ | ||
package seedu.address.logic.commands; | ||
|
||
/** | ||
* Factory enumeration class for {@code Command} objects. | ||
*/ | ||
public enum CommandType { | ||
|
||
ADD { | ||
@Override | ||
public Command createCommand(String arguments) throws IllegalArgumentException { | ||
return AddCommand.of(arguments); | ||
} | ||
}, | ||
EDIT { | ||
@Override | ||
public Command createCommand(String arguments) throws IllegalArgumentException { | ||
return EditCommand.of(arguments); | ||
} | ||
}, | ||
DELETE { | ||
@Override | ||
public Command createCommand(String arguments) throws IllegalArgumentException { | ||
return DeleteCommand.of(arguments); | ||
} | ||
}, | ||
CLEAR { | ||
@Override | ||
public Command createCommand(String arguments) { | ||
return new ClearCommand(); | ||
} | ||
}, | ||
FIND { | ||
@Override | ||
public Command createCommand(String arguments) throws IllegalArgumentException { | ||
return FindCommand.of(arguments); | ||
} | ||
}, | ||
LIST { | ||
@Override | ||
public Command createCommand(String arguments) { | ||
return new ListCommand(); | ||
} | ||
}, | ||
EXIT { | ||
@Override | ||
public Command createCommand(String arguments) { | ||
return new ExitCommand(); | ||
} | ||
}, | ||
HELP { | ||
@Override | ||
public Command createCommand(String arguments) { | ||
return new HelpCommand(); | ||
} | ||
}; | ||
|
||
public abstract Command createCommand(String arguments) throws IllegalArgumentException; | ||
} |
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
Oops, something went wrong.