From 5772020b43d2acd31962f12f2ae30ab046dbca11 Mon Sep 17 00:00:00 2001 From: juvester Date: Wed, 18 May 2016 12:31:35 +0300 Subject: [PATCH 1/2] Use Java style naming --- src/main/java/fi/helsinki/cs/tmc/cli/command/Command.java | 4 ++-- src/main/java/fi/helsinki/cs/tmc/cli/command/CommandMap.java | 2 +- src/main/java/fi/helsinki/cs/tmc/cli/command/TestCommand.java | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/fi/helsinki/cs/tmc/cli/command/Command.java b/src/main/java/fi/helsinki/cs/tmc/cli/command/Command.java index 6a25970e..52afd720 100644 --- a/src/main/java/fi/helsinki/cs/tmc/cli/command/Command.java +++ b/src/main/java/fi/helsinki/cs/tmc/cli/command/Command.java @@ -9,13 +9,13 @@ public interface Command { * Get command description. * @return Description */ - String description(); + String getDescription(); /** * Get default command name. * @return Name */ - String name(); + String getName(); /** * Run command. diff --git a/src/main/java/fi/helsinki/cs/tmc/cli/command/CommandMap.java b/src/main/java/fi/helsinki/cs/tmc/cli/command/CommandMap.java index acf4ea64..5348b506 100644 --- a/src/main/java/fi/helsinki/cs/tmc/cli/command/CommandMap.java +++ b/src/main/java/fi/helsinki/cs/tmc/cli/command/CommandMap.java @@ -16,7 +16,7 @@ public CommandMap() { } private void createCommand(Command command) { - this.commands.put(command.name(), command); + this.commands.put(command.getName(), command); } public Command getCommand(String name) { diff --git a/src/main/java/fi/helsinki/cs/tmc/cli/command/TestCommand.java b/src/main/java/fi/helsinki/cs/tmc/cli/command/TestCommand.java index ede6e5fd..5cb8b026 100644 --- a/src/main/java/fi/helsinki/cs/tmc/cli/command/TestCommand.java +++ b/src/main/java/fi/helsinki/cs/tmc/cli/command/TestCommand.java @@ -6,12 +6,12 @@ public class TestCommand implements Command { @Override - public String description() { + public String getDescription() { return "This is an easter egg test command."; } @Override - public String name() { + public String getName() { return "EasterEgg"; } From 76fcd8da55c2ae2d8f8a54df73b7bed81e9da976 Mon Sep 17 00:00:00 2001 From: juvester Date: Wed, 18 May 2016 12:53:51 +0300 Subject: [PATCH 2/2] Add some Javadocs --- .../java/fi/helsinki/cs/tmc/cli/command/Command.java | 2 -- .../fi/helsinki/cs/tmc/cli/command/CommandMap.java | 12 ++++++++++-- .../fi/helsinki/cs/tmc/cli/command/TestCommand.java | 2 -- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/main/java/fi/helsinki/cs/tmc/cli/command/Command.java b/src/main/java/fi/helsinki/cs/tmc/cli/command/Command.java index 52afd720..f175123b 100644 --- a/src/main/java/fi/helsinki/cs/tmc/cli/command/Command.java +++ b/src/main/java/fi/helsinki/cs/tmc/cli/command/Command.java @@ -4,7 +4,6 @@ * Class is an interface for commands. */ public interface Command { - /** * Get command description. * @return Description @@ -21,5 +20,4 @@ public interface Command { * Run command. */ void run(); - } diff --git a/src/main/java/fi/helsinki/cs/tmc/cli/command/CommandMap.java b/src/main/java/fi/helsinki/cs/tmc/cli/command/CommandMap.java index 5348b506..36e0029c 100644 --- a/src/main/java/fi/helsinki/cs/tmc/cli/command/CommandMap.java +++ b/src/main/java/fi/helsinki/cs/tmc/cli/command/CommandMap.java @@ -10,15 +10,23 @@ public class CommandMap { private Map commands; + /** + * Constructor. + */ public CommandMap() { this.commands = new HashMap<>(); createCommand(new TestCommand()); } - + private void createCommand(Command command) { this.commands.put(command.getName(), command); } - + + /** + * Get command by default name. + * @param name + * @return Command + */ public Command getCommand(String name) { return commands.get(name); } diff --git a/src/main/java/fi/helsinki/cs/tmc/cli/command/TestCommand.java b/src/main/java/fi/helsinki/cs/tmc/cli/command/TestCommand.java index 5cb8b026..80a3b544 100644 --- a/src/main/java/fi/helsinki/cs/tmc/cli/command/TestCommand.java +++ b/src/main/java/fi/helsinki/cs/tmc/cli/command/TestCommand.java @@ -4,7 +4,6 @@ * Class is a test command class */ public class TestCommand implements Command { - @Override public String getDescription() { return "This is an easter egg test command."; @@ -19,5 +18,4 @@ public String getName() { public void run() { System.out.println("Let's run easter egg."); } - }