#305 Prepare to remove CommandParts - replace getCount() to List#size()

- Preparations to remove the CommandParts as it's a "decorated list".
This commit is contained in:
ljacqu
2015-12-05 12:06:44 +01:00
parent 9d39fc1127
commit 61875f26fa
13 changed files with 60 additions and 51 deletions
@@ -459,11 +459,13 @@ public class CommandDescription {
*/
public FoundCommandResult findCommand(final CommandParts queryReference) {
// Make sure the command reference is valid
if (queryReference.getCount() <= 0)
List<String> queryRef = queryReference.getList();
if (queryRef.isEmpty()) {
return null;
}
// Check whether this description is for the last element in the command reference, if so return the current command
if (queryReference.getCount() <= getParentCount() + 1) {
if (queryRef.size() <= getParentCount() + 1) {
return new FoundCommandResult(
this,
getCommandReference(queryReference),
@@ -523,12 +525,13 @@ public class CommandDescription {
*/
public int getSuitableArgumentsDifference(CommandParts commandReference) {
// Make sure the command reference is valid
if (commandReference.getCount() <= 0) {
List<String> labels = commandReference.getList();
if (labels.isEmpty()) {
return -1;
}
// Get the remaining command reference element count
int remainingElementCount = commandReference.getCount() - getParentCount() - 1;
int remainingElementCount = labels.size() - getParentCount() - 1;
// Check if there are too few arguments
int minArguments = CommandUtils.getMinNumberOfArguments(this);