From dca8e9f586fd595a7995f07788318fb92b8cce79 Mon Sep 17 00:00:00 2001 From: bculkin2442 Date: Thu, 28 Jul 2016 16:44:36 -0400 Subject: Format/Cleanup pass --- .../main/java/bjc/utils/cli/GenericCommand.java | 9 ++++---- .../java/bjc/utils/cli/GenericCommandMode.java | 26 +++++++++++----------- .../src/main/java/bjc/utils/cli/ICommandHelp.java | 5 +++-- .../src/main/java/bjc/utils/cli/ICommandMode.java | 21 +++++++++-------- 4 files changed, 31 insertions(+), 30 deletions(-) (limited to 'BJC-Utils2/src/main/java/bjc/utils/cli') 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 1a95018..e73d936 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/cli/GenericCommand.java +++ b/BJC-Utils2/src/main/java/bjc/utils/cli/GenericCommand.java @@ -24,14 +24,15 @@ public class GenericCommand implements ICommand { */ public GenericCommand(ICommandHandler handler, String description, String help) { - if(handler == null) { - throw new NullPointerException("Command handler must not be null"); + if (handler == null) { + throw new NullPointerException( + "Command handler must not be null"); } - + this.handler = handler; this.help = new GenericHelp(description, help); } - + @Override public ICommand aliased() { return new DelegatingCommand(this); diff --git a/BJC-Utils2/src/main/java/bjc/utils/cli/GenericCommandMode.java b/BJC-Utils2/src/main/java/bjc/utils/cli/GenericCommandMode.java index 59d3dc3..4b3b4fd 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/cli/GenericCommandMode.java +++ b/BJC-Utils2/src/main/java/bjc/utils/cli/GenericCommandMode.java @@ -21,24 +21,24 @@ public class GenericCommandMode implements ICommandMode { /* * Contains the commands this mode handles */ - private IMap commandHandlers; - private IMap defaultHandlers; + private IMap commandHandlers; + private IMap defaultHandlers; // Contains help topics without an associated command - private IMap helpTopics; + private IMap helpTopics; // The action to execute upon encountering an unknown command - private BiConsumer unknownCommandHandler; + private BiConsumer unknownCommandHandler; // The functions to use for input/output - private Consumer errorOutput; - private Consumer normalOutput; + private Consumer errorOutput; + private Consumer normalOutput; // The name of this command mode, or null if it is unnamed - private String modeName; + private String modeName; // The custom prompt to use, or null if none is specified - private String customPrompt; + private String customPrompt; /** * Create a new generic command mode @@ -331,6 +331,11 @@ public class GenericCommandMode implements ICommandMode { return ICommandMode.super.getName(); } + @Override + public boolean isCustomPromptEnabled() { + return customPrompt != null; + } + @Override public ICommandMode process(String command, String[] args) { normalOutput.accept("\n"); @@ -414,9 +419,4 @@ public class GenericCommandMode implements ICommandMode { defaultHandlers.put("exit", buildExitCommand()); } - - @Override - public boolean isCustomPromptEnabled() { - return customPrompt != null; - } } \ No newline at end of file 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 bd81537..472d6a3 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/cli/ICommandHelp.java +++ b/BJC-Utils2/src/main/java/bjc/utils/cli/ICommandHelp.java @@ -18,8 +18,9 @@ public interface ICommandHelp { * Get the summary line for a command. * * A summary line should consist of a string of the following format - * "\t" - * where anything in angle brackets should be filled in. + * "\t" where anything in angle brackets + * should be filled in. + * * @return The summary line line for a command */ public String getSummary(); 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 f60e571..8583b80 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/cli/ICommandMode.java +++ b/BJC-Utils2/src/main/java/bjc/utils/cli/ICommandMode.java @@ -43,6 +43,15 @@ public interface ICommandMode { return ""; } + /** + * Check if this mode uses a custom prompt + * + * @return Whether or not this mode uses a custom prompt + */ + public default boolean isCustomPromptEnabled() { + return false; + } + /** * Process a command in this mode * @@ -53,17 +62,7 @@ public interface ICommandMode { * @return The command mode to use for the next command. Defaults to * returning this, and doing nothing else */ - public default ICommandMode process(String command, - String[] args) { + public default ICommandMode process(String command, String[] args) { return this; } - - /** - * Check if this mode uses a custom prompt - * - * @return Whether or not this mode uses a custom prompt - */ - public default boolean isCustomPromptEnabled() { - return false; - } } -- cgit v1.2.3