Add explict this checkstyle rule and fix violations

This commit is contained in:
broccolai 2021-01-28 09:30:10 +00:00 committed by Jason
parent a6eb44376c
commit d5259dfbe4
62 changed files with 195 additions and 192 deletions

View file

@ -123,7 +123,7 @@ public abstract class CommandManager<C> {
final @NonNull CommandRegistrationHandler commandRegistrationHandler
) {
this.commandTree = CommandTree.newTree(this);
this.commandExecutionCoordinator = commandExecutionCoordinator.apply(commandTree);
this.commandExecutionCoordinator = commandExecutionCoordinator.apply(this.commandTree);
this.commandRegistrationHandler = commandRegistrationHandler;
this.commandSuggestionEngine = new DelegatingCommandSuggestionEngineFactory<>(this).create();
/* Register service types */
@ -374,7 +374,7 @@ public abstract class CommandManager<C> {
final @NonNull Description description,
final @NonNull CommandMeta meta
) {
return commandBuilder(name, aliases, (ArgumentDescription) description, meta);
return this.commandBuilder(name, aliases, (ArgumentDescription) description, meta);
}
/**

View file

@ -240,8 +240,8 @@ public final class CommandTree<C> {
if (root.equals(this.internalTree)) {
return Pair.of(null, new NoSuchCommandException(
commandContext.getSender(),
getChain(root).stream().map(Node::getValue).collect(Collectors.toList()),
stringOrEmpty(commandQueue.peek())
this.getChain(root).stream().map(Node::getValue).collect(Collectors.toList()),
this.stringOrEmpty(commandQueue.peek())
));
}
/* If we couldn't match a child, check if there's a command attached and execute it */
@ -476,7 +476,7 @@ public final class CommandTree<C> {
final @NonNull CommandContext<C> context,
final @NonNull Queue<@NonNull String> commandQueue
) {
return getSuggestions(context, commandQueue, this.internalTree);
return this.getSuggestions(context, commandQueue, this.internalTree);
}
@SuppressWarnings("MixedMutabilityReturnType")
@ -533,7 +533,7 @@ public final class CommandTree<C> {
/* Calculate suggestions for the literal arguments */
final List<String> suggestions = new LinkedList<>();
if (commandQueue.size() <= 1) {
final String literalValue = stringOrEmpty(commandQueue.peek());
final String literalValue = this.stringOrEmpty(commandQueue.peek());
for (final Node<CommandArgument<C, ?>> argument : staticArguments) {
if (this.isPermitted(commandContext.getSender(), argument) != null) {
continue;
@ -658,7 +658,7 @@ public final class CommandTree<C> {
// Fallback: use suggestion provider of argument
commandContext.setCurrentArgument(child.getValue());
return child.getValue().getSuggestionsProvider().apply(commandContext, stringOrEmpty(commandQueue.peek()));
return child.getValue().getSuggestionsProvider().apply(commandContext, this.stringOrEmpty(commandQueue.peek()));
}
private @NonNull String stringOrEmpty(final @Nullable String string) {
@ -873,7 +873,7 @@ public final class CommandTree<C> {
leaves.add(node);
}
} else {
node.children.forEach(child -> leaves.addAll(getLeavesRaw(child)));
node.children.forEach(child -> leaves.addAll(this.getLeavesRaw(child)));
}
return leaves;
}
@ -887,7 +887,7 @@ public final class CommandTree<C> {
leaves.add(node.getValue());
}
} else {
node.children.forEach(child -> leaves.addAll(getLeaves(child)));
node.children.forEach(child -> leaves.addAll(this.getLeaves(child)));
}
return leaves;
}
@ -1024,12 +1024,12 @@ public final class CommandTree<C> {
return false;
}
final Node<?> node = (Node<?>) o;
return Objects.equals(getValue(), node.getValue());
return Objects.equals(this.getValue(), node.getValue());
}
@Override
public int hashCode() {
return Objects.hash(getValue());
return Objects.hash(this.getValue());
}
/**
@ -1052,7 +1052,7 @@ public final class CommandTree<C> {
@Override
public String toString() {
return "Node{value=" + value + '}';
return "Node{value=" + this.value + '}';
}
}

View file

@ -46,7 +46,7 @@ final class AnnotatedElementAccessor implements AnnotationAccessor {
final @NonNull Class<A> clazz
) {
try {
return element.getAnnotation(clazz);
return this.element.getAnnotation(clazz);
} catch (final NullPointerException exception) {
return null;
}

View file

@ -43,7 +43,7 @@ final class MultiDelegateAnnotationAccessor implements AnnotationAccessor {
@Override
public <A extends Annotation> @Nullable A annotation(@NonNull final Class<A> clazz) {
A instance = null;
for (final AnnotationAccessor annotationAccessor : accessors) {
for (final AnnotationAccessor annotationAccessor : this.accessors) {
instance = annotationAccessor.annotation(clazz);
if (instance != null) {
break;
@ -55,7 +55,7 @@ final class MultiDelegateAnnotationAccessor implements AnnotationAccessor {
@Override
public @NonNull Collection<@NonNull Annotation> annotations() {
final List<Annotation> annotationList = new LinkedList<>();
for (final AnnotationAccessor annotationAccessor : accessors) {
for (final AnnotationAccessor annotationAccessor : this.accessors) {
annotationList.addAll(annotationAccessor.annotations());
}
return Collections.unmodifiableCollection(annotationList);

View file

@ -57,7 +57,7 @@ public final class ParameterInjectorRegistry<C> implements InjectionService<C> {
* Create a new parameter injector registry
*/
public ParameterInjectorRegistry() {
servicePipeline.registerServiceType(new TypeToken<InjectionService<C>>() {
this.servicePipeline.registerServiceType(new TypeToken<InjectionService<C>>() {
}, this);
}

View file

@ -462,12 +462,12 @@ public class CommandArgument<C, T> implements Comparable<CommandArgument<?, ?>>,
return false;
}
final CommandArgument<?, ?> that = (CommandArgument<?, ?>) o;
return isRequired() == that.isRequired() && Objects.equals(getName(), that.getName());
return this.isRequired() == that.isRequired() && Objects.equals(this.getName(), that.getName());
}
@Override
public final int hashCode() {
return Objects.hash(isRequired(), getName());
return Objects.hash(this.isRequired(), this.getName());
}
@Override
@ -693,7 +693,7 @@ public class CommandArgument<C, T> implements Comparable<CommandArgument<?, ?>>,
*/
public @NonNull CommandArgument<@NonNull C, @NonNull T> build() {
if (this.parser == null && this.manager != null) {
this.parser = this.manager.getParserRegistry().createParser(valueType, ParserParameters.empty())
this.parser = this.manager.getParserRegistry().createParser(this.valueType, ParserParameters.empty())
.orElse(null);
}
if (this.parser == null) {

View file

@ -285,7 +285,7 @@ public final class FlagArgument<C> extends CommandArgument<C, Object> {
}
}
commandContext.store(FLAG_META_KEY, "");
return suggestions(commandContext, input);
return this.suggestions(commandContext, input);
}
/**
@ -486,7 +486,7 @@ public final class FlagArgument<C> extends CommandArgument<C, Object> {
* @return String value
*/
public String getInput() {
return input;
return this.input;
}
}

View file

@ -79,13 +79,13 @@ public class ParserParameter<T> {
return false;
}
final ParserParameter<?> that = (ParserParameter<?>) o;
return Objects.equals(key, that.key)
&& Objects.equals(expectedType, that.expectedType);
return Objects.equals(this.key, that.key)
&& Objects.equals(this.expectedType, that.expectedType);
}
@Override
public final int hashCode() {
return Objects.hash(key, expectedType);
return Objects.hash(this.key, this.expectedType);
}
}

View file

@ -96,7 +96,7 @@ public final class RegexPreprocessor<C> implements BiFunction<@NonNull CommandCo
context
));
}
if (predicate.test(head)) {
if (this.predicate.test(head)) {
return ArgumentParseResult.success(true);
}
return ArgumentParseResult.failure(

View file

@ -184,7 +184,7 @@ public final class BooleanArgument<C> extends CommandArgument<C, Boolean> {
}
inputQueue.remove();
if (!liberal) {
if (!this.liberal) {
if (input.equalsIgnoreCase("true")) {
return ArgumentParseResult.success(true);
}
@ -214,7 +214,7 @@ public final class BooleanArgument<C> extends CommandArgument<C, Boolean> {
final @NonNull CommandContext<C> commandContext,
final @NonNull String input
) {
if (!liberal) {
if (!this.liberal) {
return Arrays.asList("TRUE", "FALSE");
}
@ -267,7 +267,7 @@ public final class BooleanArgument<C> extends CommandArgument<C, Boolean> {
* @return String value
*/
public String getInput() {
return input;
return this.input;
}
/**
@ -276,7 +276,7 @@ public final class BooleanArgument<C> extends CommandArgument<C, Boolean> {
* @return Liberal value
*/
public boolean isLiberal() {
return liberal;
return this.liberal;
}
}

View file

@ -183,7 +183,7 @@ public final class CharArgument<C> extends CommandArgument<C, Character> {
* @return Input value
*/
public @NonNull String getInput() {
return input;
return this.input;
}
}

View file

@ -190,7 +190,7 @@ public final class UUIDArgument<C> extends CommandArgument<C, UUID> {
* @return String value
*/
public String getInput() {
return input;
return this.input;
}
}

View file

@ -57,7 +57,7 @@ public final class Caption {
return false;
}
final Caption caption = (Caption) o;
return Objects.equals(key, caption.key);
return Objects.equals(this.key, caption.key);
}
/**
@ -71,7 +71,7 @@ public final class Caption {
@Override
public int hashCode() {
return Objects.hash(key);
return Objects.hash(this.key);
}
@Override

View file

@ -92,9 +92,9 @@ public final class AmbiguousNodeException extends IllegalStateException {
@Override
public String getMessage() {
final StringBuilder stringBuilder = new StringBuilder("Ambiguous Node: ")
.append(ambiguousNode.getName())
.append(this.ambiguousNode.getName())
.append(" cannot be added as a child to ")
.append(parentNode == null ? "<root>" : parentNode.getName())
.append(this.parentNode == null ? "<root>" : this.parentNode.getName())
.append(" (All children: ");
final Iterator<CommandArgument<?, ?>> childIterator = this.children.iterator();
while (childIterator.hasNext()) {

View file

@ -88,7 +88,7 @@ public final class InvalidCommandSenderException extends CommandParseException {
return String.format(
"%s is not allowed to execute that command. Must be of type %s",
getCommandSender().getClass().getSimpleName(),
requiredSender.getSimpleName()
this.requiredSender.getSimpleName()
);
}

View file

@ -80,7 +80,7 @@ public final class CommandPostprocessingContext<C> {
return false;
}
final CommandPostprocessingContext<?> that = (CommandPostprocessingContext<?>) o;
return Objects.equals(getCommandContext(), that.getCommandContext())
return Objects.equals(this.getCommandContext(), that.getCommandContext())
&& Objects.equals(this.getCommand(), that.getCommand());
}

View file

@ -81,13 +81,13 @@ public final class CommandPreprocessingContext<C> {
return false;
}
final CommandPreprocessingContext<?> that = (CommandPreprocessingContext<?>) o;
return Objects.equals(getCommandContext(), that.getCommandContext())
&& Objects.equals(getInputQueue(), that.getInputQueue());
return Objects.equals(this.getCommandContext(), that.getCommandContext())
&& Objects.equals(this.getInputQueue(), that.getInputQueue());
}
@Override
public int hashCode() {
return Objects.hash(getCommandContext(), getInputQueue());
return Objects.hash(this.getCommandContext(), this.getInputQueue());
}
}

View file

@ -182,9 +182,9 @@ public class CommandConfirmationManager<C> {
return;
}
/* Add it to the "queue" */
addPending(context);
CommandConfirmationManager.this.addPending(context);
/* Notify the consumer that a confirmation is required */
notifyConsumer(context);
CommandConfirmationManager.this.notifyConsumer(context);
/* Interrupt */
ConsumerService.interrupt();
}

View file

@ -56,12 +56,12 @@ public final class CommandInputTokenizer {
* @return Linked list containing the tokenized input
*/
public @NonNull LinkedList<@NonNull String> tokenize() {
final StringTokenizer stringTokenizer = stringTokenizerFactory.createStringTokenizer();
final StringTokenizer stringTokenizer = this.stringTokenizerFactory.createStringTokenizer();
final LinkedList<String> tokens = new LinkedList<>();
while (stringTokenizer.hasMoreElements()) {
tokens.add(stringTokenizer.nextToken());
}
if (input.endsWith(DELIMITER)) {
if (this.input.endsWith(DELIMITER)) {
tokens.add(EMPTY);
}
return tokens;
@ -74,7 +74,7 @@ public final class CommandInputTokenizer {
private final class StringTokenizerFactory {
private @NonNull StringTokenizer createStringTokenizer() {
return new StringTokenizer(input, DELIMITER);
return new StringTokenizer(CommandInputTokenizer.this.input, DELIMITER);
}
}

View file

@ -76,7 +76,7 @@ public final class SimpleCloudKey<@NonNull T> implements CloudKey<T> {
@Override
public @NonNull String getName() {
return name;
return this.name;
}
@Override
@ -93,12 +93,12 @@ public final class SimpleCloudKey<@NonNull T> implements CloudKey<T> {
return false;
}
final SimpleCloudKey<?> key = (SimpleCloudKey<?>) o;
return name.equals(key.name);
return this.name.equals(key.name);
}
@Override
public int hashCode() {
return Objects.hash(name);
return Objects.hash(this.name);
}
@Override

View file

@ -97,12 +97,12 @@ public final class Permission implements CommandPermission {
return false;
}
final Permission that = (Permission) o;
return Objects.equals(getPermission(), that.getPermission());
return Objects.equals(this.getPermission(), that.getPermission());
}
@Override
public int hashCode() {
return Objects.hash(getPermission());
return Objects.hash(this.getPermission());
}
}

View file

@ -89,13 +89,13 @@ public class Pair<U, V> implements Tuple {
return false;
}
final Pair<?, ?> pair = (Pair<?, ?>) o;
return Objects.equals(getFirst(), pair.getFirst())
&& Objects.equals(getSecond(), pair.getSecond());
return Objects.equals(this.getFirst(), pair.getFirst())
&& Objects.equals(this.getSecond(), pair.getSecond());
}
@Override
public final int hashCode() {
return Objects.hash(getFirst(), getSecond());
return Objects.hash(this.getFirst(), this.getSecond());
}
@Override

View file

@ -121,15 +121,15 @@ public class Quartet<U, V, W, X> implements Tuple {
return false;
}
final Quartet<?, ?, ?, ?> quartet = (Quartet<?, ?, ?, ?>) o;
return Objects.equals(getFirst(), quartet.getFirst())
&& Objects.equals(getSecond(), quartet.getSecond())
&& Objects.equals(getThird(), quartet.getThird())
&& Objects.equals(getFourth(), quartet.getFourth());
return Objects.equals(this.getFirst(), quartet.getFirst())
&& Objects.equals(this.getSecond(), quartet.getSecond())
&& Objects.equals(this.getThird(), quartet.getThird())
&& Objects.equals(this.getFourth(), quartet.getFourth());
}
@Override
public final int hashCode() {
return Objects.hash(getFirst(), getSecond(), getThird(), getFourth());
return Objects.hash(this.getFirst(), this.getSecond(), this.getThird(), this.getFourth());
}
@Override

View file

@ -137,16 +137,16 @@ public class Quintet<U, V, W, X, Y> implements Tuple {
return false;
}
final Quintet<?, ?, ?, ?, ?> quintet = (Quintet<?, ?, ?, ?, ?>) o;
return Objects.equals(getFirst(), quintet.getFirst())
&& Objects.equals(getSecond(), quintet.getSecond())
&& Objects.equals(getThird(), quintet.getThird())
&& Objects.equals(getFourth(), quintet.getFourth())
&& Objects.equals(getFifth(), quintet.getFifth());
return Objects.equals(this.getFirst(), quintet.getFirst())
&& Objects.equals(this.getSecond(), quintet.getSecond())
&& Objects.equals(this.getThird(), quintet.getThird())
&& Objects.equals(this.getFourth(), quintet.getFourth())
&& Objects.equals(this.getFifth(), quintet.getFifth());
}
@Override
public final int hashCode() {
return Objects.hash(getFirst(), getSecond(), getThird(), getFourth(), getFifth());
return Objects.hash(this.getFirst(), this.getSecond(), this.getThird(), this.getFourth(), this.getFifth());
}
@Override

View file

@ -153,17 +153,17 @@ public class Sextet<U, V, W, X, Y, Z> implements Tuple {
return false;
}
final Sextet<?, ?, ?, ?, ?, ?> sextet = (Sextet<?, ?, ?, ?, ?, ?>) o;
return Objects.equals(getFirst(), sextet.getFirst())
&& Objects.equals(getSecond(), sextet.getSecond())
&& Objects.equals(getThird(), sextet.getThird())
&& Objects.equals(getFourth(), sextet.getFourth())
&& Objects.equals(getFifth(), sextet.getFifth())
&& Objects.equals(getSixth(), sextet.getSixth());
return Objects.equals(this.getFirst(), sextet.getFirst())
&& Objects.equals(this.getSecond(), sextet.getSecond())
&& Objects.equals(this.getThird(), sextet.getThird())
&& Objects.equals(this.getFourth(), sextet.getFourth())
&& Objects.equals(this.getFifth(), sextet.getFifth())
&& Objects.equals(this.getSixth(), sextet.getSixth());
}
@Override
public final int hashCode() {
return Objects.hash(getFirst(), getSecond(), getThird(), getFourth(), getFifth(), getSixth());
return Objects.hash(this.getFirst(), this.getSecond(), this.getThird(), this.getFourth(), this.getFifth(), this.getSixth());
}
@Override

View file

@ -105,14 +105,14 @@ public class Triplet<U, V, W> implements Tuple {
return false;
}
final Triplet<?, ?, ?> triplet = (Triplet<?, ?, ?>) o;
return Objects.equals(getFirst(), triplet.getFirst())
&& Objects.equals(getSecond(), triplet.getSecond())
&& Objects.equals(getThird(), triplet.getThird());
return Objects.equals(this.getFirst(), triplet.getFirst())
&& Objects.equals(this.getSecond(), triplet.getSecond())
&& Objects.equals(this.getThird(), triplet.getThird());
}
@Override
public final int hashCode() {
return Objects.hash(getFirst(), getSecond(), getThird());
return Objects.hash(this.getFirst(), this.getSecond(), this.getThird());
}
@Override