Gets the next (more recent) command from the history. @return The next command or null if no next command is available.
()
| 78 | * @return The next command or {@code null} if no next command is available. |
| 79 | */ |
| 80 | public String getNextCommand() { |
| 81 | |
| 82 | // Return null if there is no next command available. |
| 83 | if (!this.hasNextCommand()) { |
| 84 | return null; |
| 85 | } |
| 86 | |
| 87 | // Get next command. |
| 88 | String next = this.iterator.next(); |
| 89 | |
| 90 | // Reset 'current' command when at the end of the list. |
| 91 | if (this.iterator.nextIndex() == this.commandHistory.size()) { |
| 92 | this.iterator.set(""); // Reset 'current' command. |
| 93 | } |
| 94 | return next; |
| 95 | } |
| 96 | |
| 97 | /** |
| 98 | * Gets whether a previous (older) command is available in the history. |
no test coverage detected