From 42f7d379a430aaf2fad169f0170de04072b08b10 Mon Sep 17 00:00:00 2001 From: bculkin2442 Date: Fri, 22 Apr 2016 14:48:04 -0400 Subject: Formatting changes --- .../src/main/java/bjc/utils/cli/CLICommander.java | 30 ++++++------ .../main/java/bjc/utils/cli/DelegatingCommand.java | 10 ++-- .../main/java/bjc/utils/cli/GenericCommand.java | 20 ++++---- .../src/main/java/bjc/utils/cli/GenericHelp.java | 8 ++-- .../src/main/java/bjc/utils/cli/ICommand.java | 14 +++--- .../src/main/java/bjc/utils/cli/ICommandHelp.java | 14 +++--- .../src/main/java/bjc/utils/cli/ICommandMode.java | 54 +++++++++++----------- 7 files changed, 75 insertions(+), 75 deletions(-) (limited to 'BJC-Utils2/src/main/java/bjc/utils/cli') diff --git a/BJC-Utils2/src/main/java/bjc/utils/cli/CLICommander.java b/BJC-Utils2/src/main/java/bjc/utils/cli/CLICommander.java index e816b78..09d3da7 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/cli/CLICommander.java +++ b/BJC-Utils2/src/main/java/bjc/utils/cli/CLICommander.java @@ -47,21 +47,6 @@ public class CLICommander { this.error = error; } - /** - * Set the initial command mode to use - * - * @param initialMode - * The initial command mode to use - */ - public void setInitialCommandMode(ICommandMode initialMode) { - if (initialMode == null) { - throw new NullPointerException( - "Initial mode must be non-zero"); - } - - this.initialMode = initialMode; - } - /** * Run a set of commands through this commander */ @@ -105,4 +90,19 @@ public class CLICommander { normalOutput.print("Exiting now."); } + + /** + * Set the initial command mode to use + * + * @param initialMode + * The initial command mode to use + */ + public void setInitialCommandMode(ICommandMode initialMode) { + if (initialMode == null) { + throw new NullPointerException( + "Initial mode must be non-zero"); + } + + this.initialMode = initialMode; + } } diff --git a/BJC-Utils2/src/main/java/bjc/utils/cli/DelegatingCommand.java b/BJC-Utils2/src/main/java/bjc/utils/cli/DelegatingCommand.java index 76794cf..28e0347 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/cli/DelegatingCommand.java +++ b/BJC-Utils2/src/main/java/bjc/utils/cli/DelegatingCommand.java @@ -7,6 +7,11 @@ class DelegatingCommand implements ICommand { this.delegate = delegate; } + @Override + public ICommand createAlias() { + return new DelegatingCommand(delegate); + } + @Override public ICommandHandler getHandler() { return delegate.getHandler(); @@ -17,11 +22,6 @@ class DelegatingCommand implements ICommand { return delegate.getHelp(); } - @Override - public ICommand createAlias() { - return new DelegatingCommand(delegate); - } - @Override public boolean isAlias() { return true; diff --git a/BJC-Utils2/src/main/java/bjc/utils/cli/GenericCommand.java b/BJC-Utils2/src/main/java/bjc/utils/cli/GenericCommand.java index 3c0aef6..fad1199 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/cli/GenericCommand.java +++ b/BJC-Utils2/src/main/java/bjc/utils/cli/GenericCommand.java @@ -26,6 +26,16 @@ public class GenericCommand implements ICommand { this.help = new GenericHelp(description, help); } + /** + * Create a command that is an alias to this one + * + * @return A command that is an alias to this one + */ + @Override + public ICommand createAlias() { + return new DelegatingCommand(this); + } + @Override public ICommandHandler getHandler() { return handler; @@ -40,14 +50,4 @@ public class GenericCommand implements ICommand { public boolean isAlias() { return false; } - - /** - * Create a command that is an alias to this one - * - * @return A command that is an alias to this one - */ - @Override - public ICommand createAlias() { - return new DelegatingCommand(this); - } } diff --git a/BJC-Utils2/src/main/java/bjc/utils/cli/GenericHelp.java b/BJC-Utils2/src/main/java/bjc/utils/cli/GenericHelp.java index f508de8..f2fb146 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/cli/GenericHelp.java +++ b/BJC-Utils2/src/main/java/bjc/utils/cli/GenericHelp.java @@ -24,13 +24,13 @@ public class GenericHelp implements ICommandHelp { } @Override - public String getSummary() { - return summary; + public String getDescription() { + return description; } @Override - public String getDescription() { - return description; + public String getSummary() { + return summary; } } \ No newline at end of file diff --git a/BJC-Utils2/src/main/java/bjc/utils/cli/ICommand.java b/BJC-Utils2/src/main/java/bjc/utils/cli/ICommand.java index 7029829..ff15a37 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/cli/ICommand.java +++ b/BJC-Utils2/src/main/java/bjc/utils/cli/ICommand.java @@ -7,6 +7,13 @@ package bjc.utils.cli; * */ public interface ICommand { + /** + * Create a command that serves as an alias to this one + * + * @return A command that serves as an alias to this one + */ + public ICommand createAlias(); + /** * Get the handler that executes this command * @@ -21,13 +28,6 @@ public interface ICommand { */ public ICommandHelp getHelp(); - /** - * Create a command that serves as an alias to this one - * - * @return A command that serves as an alias to this one - */ - public ICommand createAlias(); - /** * Check if this command is an alias of another command * diff --git a/BJC-Utils2/src/main/java/bjc/utils/cli/ICommandHelp.java b/BJC-Utils2/src/main/java/bjc/utils/cli/ICommandHelp.java index ad03dac..d475335 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/cli/ICommandHelp.java +++ b/BJC-Utils2/src/main/java/bjc/utils/cli/ICommandHelp.java @@ -7,6 +7,13 @@ package bjc.utils.cli; * */ public interface ICommandHelp { + /** + * Get the description of a command + * + * @return The description of a command + */ + public String getDescription(); + /** * Get the summary line for a command * @@ -16,11 +23,4 @@ public interface ICommandHelp { * @return The summary line line for a command */ public String getSummary(); - - /** - * Get the description of a command - * - * @return The description of a command - */ - public String getDescription(); } diff --git a/BJC-Utils2/src/main/java/bjc/utils/cli/ICommandMode.java b/BJC-Utils2/src/main/java/bjc/utils/cli/ICommandMode.java index 5208657..f6313af 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/cli/ICommandMode.java +++ b/BJC-Utils2/src/main/java/bjc/utils/cli/ICommandMode.java @@ -8,21 +8,6 @@ package bjc.utils.cli; * */ public interface ICommandMode { - /** - * Process a command in this mode - * - * @param command - * The command to process - * @param args - * A list of arguments to the command - * @return The command mode to use for the next command. Defaults to - * returning this, and doing nothing else - */ - public default ICommandMode processCommand(String command, - String[] args) { - return this; - }; - /** * Check to see if this mode can handle the specified command * @@ -33,6 +18,19 @@ public interface ICommandMode { */ public default boolean canHandleCommand(String command) { return false; + }; + + /** + * Get the custom prompt for this mode + * + * @return the custom prompt for this mode + * + * @throws UnsupportedOperationException + * if this mode doesn't support a custom prompt + */ + public default String getCustomPrompt() { + throw new UnsupportedOperationException( + "This mode doesn't support a custom prompt"); } /** @@ -45,24 +43,26 @@ public interface ICommandMode { } /** - * Check if this mode uses a custom prompt + * Process a command in this mode * - * @return Whether or not this mode uses a custom prompt + * @param command + * The command to process + * @param args + * A list of arguments to the command + * @return The command mode to use for the next command. Defaults to + * returning this, and doing nothing else */ - public default boolean useCustomPrompt() { - return false; + public default ICommandMode processCommand(String command, + String[] args) { + return this; } /** - * Get the custom prompt for this mode - * - * @return the custom prompt for this mode + * Check if this mode uses a custom prompt * - * @throws UnsupportedOperationException - * if this mode doesn't support a custom prompt + * @return Whether or not this mode uses a custom prompt */ - public default String getCustomPrompt() { - throw new UnsupportedOperationException( - "This mode doesn't support a custom prompt"); + public default boolean useCustomPrompt() { + return false; } } -- cgit v1.2.3