SPIGOT-2540: Add nullability annotations to entire Bukkit API
By: Darkyenus <darkyenus@gmail.com>
This commit is contained in:
@@ -2,6 +2,8 @@ package org.bukkit.conversations;
|
||||
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.apache.commons.lang.BooleanUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* BooleanPrompt is the base class for any prompt that requires a boolean
|
||||
@@ -14,13 +16,14 @@ public abstract class BooleanPrompt extends ValidatingPrompt {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isInputValid(ConversationContext context, String input) {
|
||||
protected boolean isInputValid(@NotNull ConversationContext context, @NotNull String input) {
|
||||
String[] accepted = {/* Apache values: */"true", "false", "on", "off", "yes", "no",/* Additional values: */ "y", "n", "1", "0", "right", "wrong", "correct", "incorrect", "valid", "invalid"};
|
||||
return ArrayUtils.contains(accepted, input.toLowerCase());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected Prompt acceptValidatedInput(ConversationContext context, String input) {
|
||||
protected Prompt acceptValidatedInput(@NotNull ConversationContext context, @NotNull String input) {
|
||||
if (input.equalsIgnoreCase("y") || input.equals("1") || input.equalsIgnoreCase("right") || input.equalsIgnoreCase("correct") || input.equalsIgnoreCase("valid")) input = "true";
|
||||
return acceptValidatedInput(context, BooleanUtils.toBoolean(input));
|
||||
}
|
||||
@@ -33,5 +36,6 @@ public abstract class BooleanPrompt extends ValidatingPrompt {
|
||||
* @param input The user's boolean response.
|
||||
* @return The next {@link Prompt} in the prompt graph.
|
||||
*/
|
||||
protected abstract Prompt acceptValidatedInput(ConversationContext context, boolean input);
|
||||
@Nullable
|
||||
protected abstract Prompt acceptValidatedInput(@NotNull ConversationContext context, boolean input);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user