1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-10-11 20:17:39 +00:00

Switch the core library to be non-null by default

See comments in c8c128d335 for further
details. This requires /relatively/ few changes - mostly cases we were
missing @Nullable annotations.
This commit is contained in:
Jonathan Coates
2022-11-06 11:55:26 +00:00
parent c8c128d335
commit c82f37d3bf
88 changed files with 465 additions and 626 deletions

View File

@@ -18,6 +18,7 @@ dependencies {
compileOnly(project(":mc-stubs"))
compileOnlyApi(libs.jsr305)
compileOnlyApi(libs.checkerFramework)
compileOnlyApi(libs.jetbrainsAnnotations)
"docApi"(project(":"))
}

View File

@@ -5,6 +5,8 @@
*/
package dan200.computercraft.api.lua;
import org.jetbrains.annotations.Contract;
import javax.annotation.Nullable;
import java.nio.ByteBuffer;
import java.util.Map;
@@ -387,7 +389,9 @@ public interface IArguments {
* @return The argument's value, or {@code def} if none was provided.
* @throws LuaException If the value is not a string.
*/
default String optString(int index, String def) throws LuaException {
@Nullable
@Contract("_, !null -> !null")
default String optString(int index, @Nullable String def) throws LuaException {
return optString(index).orElse(def);
}
@@ -399,7 +403,9 @@ public interface IArguments {
* @return The argument's value, or {@code def} if none was provided.
* @throws LuaException If the value is not a table.
*/
default Map<?, ?> optTable(int index, Map<Object, Object> def) throws LuaException {
@Nullable
@Contract("_, !null -> !null")
default Map<?, ?> optTable(int index, @Nullable Map<Object, Object> def) throws LuaException {
return optTable(index).orElse(def);
}
}

View File

@@ -86,6 +86,7 @@ public interface IComputerAccess {
* @see #unmount(String)
* @see IMount
*/
@Nullable
String mountWritable(String desiredLocation, IWritableMount mount, String driveName);
/**