Skip to content

Commit 8e4597a

Browse files
authored
fix nullability issues (#2455)
* fix nullability issues * add missing package-info files * more nullability fixes * more nullability fixes * fix missorted modifier * run spotless apply
1 parent f69db9f commit 8e4597a

File tree

54 files changed

+897
-41
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+897
-41
lines changed

src/ap/java/org/spongepowered/plugin/processor/ListenerProcessor.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
import static javax.tools.Diagnostic.Kind.ERROR;
2828

29+
import org.checkerframework.checker.nullness.qual.Nullable;
2930
import org.spongepowered.api.event.Event;
3031
import org.spongepowered.api.event.Listener;
3132
import org.spongepowered.api.event.filter.IsCancelled;
@@ -99,7 +100,7 @@ public boolean process(final Set<? extends TypeElement> annotations, final Round
99100
this.error("Event listener method must return void", method);
100101
}
101102
final List<? extends VariableElement> parameters = method.getParameters();
102-
final DeclaredType eventType;
103+
final @Nullable DeclaredType eventType;
103104
if (parameters.isEmpty() || !this.isTypeSubclass(parameters.get(0), ListenerProcessor.EVENT_CLASS)) {
104105
this.error("Event listener method must have an Event as its first parameter", method);
105106
eventType = null;

src/main/java/org/spongepowered/api/Sponge.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
*/
4444
public final class Sponge {
4545

46-
@Inject private @Nullable static Game game;
46+
@Inject private static @Nullable Game game;
4747

4848
/**
4949
* Gets the {@link Game} instance. There is ever only going

src/main/java/org/spongepowered/api/block/transaction/BlockTransaction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public BlockTransaction(final BlockSnapshot original, final BlockSnapshot defaul
5555
}
5656

5757
public BlockTransaction(final BlockSnapshot original, final BlockSnapshot defaultReplacement,
58-
@Nullable final List<? extends BlockSnapshot> intermediary,
58+
final @Nullable List<? extends BlockSnapshot> intermediary,
5959
final Operation operation
6060
) {
6161
super(original, defaultReplacement, intermediary);
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* This file is part of SpongeAPI, licensed under the MIT License (MIT).
3+
*
4+
* Copyright (c) SpongePowered <https://www.spongepowered.org>
5+
* Copyright (c) contributors
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in
15+
* all copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
* THE SOFTWARE.
24+
*/
25+
/**
26+
* An API section where "blocks" are represented. A block is a tile in the 3D
27+
* game universe. Each "block" has a
28+
* {@link org.spongepowered.api.block.BlockState} that can be changed.
29+
*/
30+
@org.checkerframework.framework.qual.DefaultQualifier(org.checkerframework.checker.nullness.qual.NonNull.class)
31+
package org.spongepowered.api.block.transaction;

src/main/java/org/spongepowered/api/command/Command.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ default Builder addParameters(final Iterable<Parameter> parameters) {
509509
* for no description.
510510
* @return This builder, for chaining
511511
*/
512-
default Builder extendedDescription(@Nullable final Component extendedDescription) {
512+
default Builder extendedDescription(final @Nullable Component extendedDescription) {
513513
// Done outside the lambda so that we don't have to recreate the object each time.
514514
final Optional<Component> text = Optional.ofNullable(extendedDescription);
515515
return this.extendedDescription((cause) -> text);
@@ -543,7 +543,7 @@ default Builder extendedDescription(@Nullable final Component extendedDescriptio
543543
* description
544544
* @return This builder, for chaining
545545
*/
546-
default Builder shortDescription(@Nullable final Component description) {
546+
default Builder shortDescription(final @Nullable Component description) {
547547
// Done outside the lambda so that we don't have to recreate the object each time.
548548
final Optional<Component> text = Optional.ofNullable(description);
549549
return this.shortDescription((cause) -> text);

src/main/java/org/spongepowered/api/command/exception/CommandException.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
package org.spongepowered.api.command.exception;
2626

2727
import net.kyori.adventure.text.Component;
28+
import org.checkerframework.checker.nullness.qual.Nullable;
2829
import org.spongepowered.api.util.ComponentMessageException;
2930

3031
/**
@@ -42,7 +43,7 @@ public class CommandException extends ComponentMessageException {
4243
*
4344
* @param message The detail message
4445
*/
45-
public CommandException(final Component message) {
46+
public CommandException(final @Nullable Component message) {
4647
this(message, false);
4748
}
4849

@@ -53,7 +54,7 @@ public CommandException(final Component message) {
5354
* @param message The detail message
5455
* @param cause The cause
5556
*/
56-
public CommandException(final Component message, final Throwable cause) {
57+
public CommandException(final @Nullable Component message, final Throwable cause) {
5758
this(message, cause, false);
5859
}
5960

@@ -63,7 +64,7 @@ public CommandException(final Component message, final Throwable cause) {
6364
* @param message The detail message
6465
* @param includeUsage Whether to include usage in the exception
6566
*/
66-
public CommandException(final Component message, final boolean includeUsage) {
67+
public CommandException(final @Nullable Component message, final boolean includeUsage) {
6768
super(message);
6869
this.includeUsage = includeUsage;
6970
}
@@ -76,7 +77,7 @@ public CommandException(final Component message, final boolean includeUsage) {
7677
* @param cause The cause
7778
* @param includeUsage Whether to include the usage in the exception
7879
*/
79-
public CommandException(final Component message, final Throwable cause, final boolean includeUsage) {
80+
public CommandException(final @Nullable Component message, final Throwable cause, final boolean includeUsage) {
8081
super(message, cause);
8182
this.includeUsage = includeUsage;
8283
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* This file is part of SpongeAPI, licensed under the MIT License (MIT).
3+
*
4+
* Copyright (c) SpongePowered <https://www.spongepowered.org>
5+
* Copyright (c) contributors
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in
15+
* all copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
* THE SOFTWARE.
24+
*/
25+
@org.checkerframework.framework.qual.DefaultQualifier(org.checkerframework.checker.nullness.qual.NonNull.class)
26+
package org.spongepowered.api.command.parameter.managed.clientcompletion;
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* This file is part of SpongeAPI, licensed under the MIT License (MIT).
3+
*
4+
* Copyright (c) SpongePowered <https://www.spongepowered.org>
5+
* Copyright (c) contributors
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in
15+
* all copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
* THE SOFTWARE.
24+
*/
25+
@org.checkerframework.framework.qual.DefaultQualifier(org.checkerframework.checker.nullness.qual.NonNull.class)
26+
package org.spongepowered.api.command.parameter.managed.operator;
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* This file is part of SpongeAPI, licensed under the MIT License (MIT).
3+
*
4+
* Copyright (c) SpongePowered <https://www.spongepowered.org>
5+
* Copyright (c) contributors
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in
15+
* all copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
* THE SOFTWARE.
24+
*/
25+
@org.checkerframework.framework.qual.DefaultQualifier(org.checkerframework.checker.nullness.qual.NonNull.class)
26+
package org.spongepowered.api.command.registrar;

src/main/java/org/spongepowered/api/command/registrar/tree/CommandTreeNode.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ default <C extends CommandTreeNode.Argument<C>> T child(final String key, final
180180
* @param completionProvider The provider this node should use
181181
* @return This, for chaining
182182
*/
183-
default T completions(@Nullable final DefaultedRegistryReference<CommandCompletionProvider> completionProvider) {
183+
default T completions(final @Nullable DefaultedRegistryReference<CommandCompletionProvider> completionProvider) {
184184
if (completionProvider == null) {
185185
return this.completions((CommandCompletionProvider) null);
186186
}

0 commit comments

Comments
 (0)