public abstract class LiteralCommandMap extends Object
| Modifier and Type | Field and Description |
|---|---|
private SubCommandType |
defaultSubCommand
Default sub command for commands w/o sub commands.
|
private Map<String,MainCommandType> |
mainCommands
Map the literal command string to corresponding type enum.
|
private Map<String,SubCommandType> |
subCommands
Map the literal sub command string to corresponding type enum.
|
| Constructor and Description |
|---|
LiteralCommandMap(SubCommandType defaultSubCommand)
Dedicated constructor.
|
| Modifier and Type | Method and Description |
|---|---|
MainCommandType |
determineCommand(Token t)
Determines the appropriate main command type for given string token.
|
SubCommandType |
determineSubCommand(Token t)
Determines the appropriate sub command type for given string token.
|
SubCommandType |
getDefaultSubCommand()
Get the default sub command for commands w/o sub commands.
|
protected abstract Class<? extends MainCommandType> |
getMainCommandType()
Return here the enum type which declares your main commands.
|
protected abstract Class<? extends SubCommandType> |
getSubCommandType()
Return here the enum type which declares your sub commands.
|
private void |
init()
Not overideable template method called in constructor.
|
private void |
initMainCommandMap()
Initializes the command map.
|
private void |
initSubCommandMap()
Initializes the sub command map.
|
boolean |
isCommand(String token)
Determines if the string literal value is a main command.
|
boolean |
isCommand(Token token)
Determines if the string literal value of the token is a main command.
|
boolean |
isSubCommand(String token)
Determines if the string literal value is a sub command.
|
boolean |
isSubCommand(Token token)
Determines if the string literal value of the token is a sub command.
|
private final Map<String,MainCommandType> mainCommands
private final Map<String,SubCommandType> subCommands
private final SubCommandType defaultSubCommand
public LiteralCommandMap(SubCommandType defaultSubCommand)
defaultSubCommand - sub command used for commands w/o sub command,
usually a NONE type, must not be nullpublic final boolean isCommand(Token token)
token - token to checkpublic final boolean isCommand(String token)
token - token string to checkpublic final MainCommandType determineCommand(Token t)
t - token to checkIllegalArgumentException - if, token is not a main command
// CHECKSTYLE:ONpublic final boolean isSubCommand(Token token)
token - token to checkpublic final boolean isSubCommand(String token)
token - token string to checkpublic final SubCommandType determineSubCommand(Token t)
t - token to checkIllegalArgumentException - if, token is not a sub command
// CHECKSTYLE:ONpublic final SubCommandType getDefaultSubCommand()
protected abstract Class<? extends MainCommandType> getMainCommandType()
nullprivate void initMainCommandMap()
private void initSubCommandMap()
protected abstract Class<? extends SubCommandType> getSubCommandType()
nullprivate void init()
Copyright © 2014 Sven Strittmatter. All Rights Reserved.