blob: 29857e00be8697bd1d9d697b08a81aa1885a5fc8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
package bjc.utils.cli.fds;
import bjc.utils.cli.CommandHelp;
import bjc.utils.cli.NullHelp;
/**
* A collection of related FDS commands.
*
* @author bjculkin
*
* @param <S>
* The FDS state type.
*/
public interface FDSMode<S> {
/**
* Get the name of this mode.
*
* @return The mode of this name.
*/
default String getName() {
return "Unnamed Mode";
}
/**
* Get all the characters that are registered to something in this mode.
*
* In this context, something means a command or submode.
*
* @return All of the characters registered to something in this mode.
*/
char[] registeredChars();
/*
* Check for the existence of commands/submodes.
*/
/**
* Check if there is a command registered to the given character.
*
* @param c
* The character to check
*
* @return Whether or not there is a command bound to that character.
*/
boolean hasCommand(char c);
/**
* Check if there is a submode registered to the given character.
*
* @param c
* The character to check
*
* @return Whether or not there is a submode bound to that character.
*/
boolean hasSubmode(char c);
/*
* Get commands and submodes.
*/
/**
* Get the command attached to a given character.
*
* @param c
* The character to get the command for.
*
* @return The command bound to that character.
*
* @throws FDSException
* If there is no command bound to that character.
*/
FDSCommand<S> getCommand(char c) throws FDSException;
/**
* Get the command attached to a given character.
*
* @param c
* The character to get the command for.
*
* @return The command bound to that character.
*
* @throws FDSException
* If there is no command bound to that character.
*/
FDSMode<S> getSubmode(char c) throws FDSException;
/*
* Help utilities
*/
/**
* Get the help for what's bound to a character.
*
* This should be one line.
*
* @param c
* The character to look at the help for.
*
* @return The help for what's bound to the character.
*/
default CommandHelp getHelp(char c) {
return new NullHelp();
}
}
|