From 5be405391d793194195d14031841e189b3b29302 Mon Sep 17 00:00:00 2001
From: Octavia Togami
Date: Tue, 25 Jun 2024 19:18:52 -0700
Subject: [PATCH] Switch to jspecify
---
common/build.gradle.kts | 4 +-
common/src/main/java/module-info.java | 5 +-
.../enginehub/linbus/common/IOFunction.java | 4 +-
.../common/internal/AbstractIterator.java | 4 +-
format-snbt/build.gradle.kts | 4 +-
format-snbt/src/main/java/module-info.java | 5 +-
.../linbus/format/snbt/LinStringIO.java | 13 ++-
.../format/snbt/impl/LinSnbtWriter.java | 3 +-
.../snbt/impl/reader/LinSnbtReader.java | 11 ++-
.../snbt/impl/reader/LinSnbtTokenizer.java | 8 +-
.../linbus/format/snbt/impl/package-info.java | 22 +++++
.../format/snbt/impl/reader/package-info.java | 22 +++++
.../linbus/format/snbt/package-info.java | 22 +++++
.../linbus/format/snbt/util/TracedReader.java | 8 +-
.../linbus/format/snbt/util/package-info.java | 22 +++++
gradle/libs.versions.toml | 10 +--
stream/build.gradle.kts | 7 +-
stream/src/main/java/module-info.java | 5 +-
.../enginehub/linbus/stream/LinBinaryIO.java | 10 +--
.../enginehub/linbus/stream/LinStream.java | 9 +-
.../linbus/stream/LinStreamable.java | 4 +-
.../linbus/stream/impl/LinNbtReader.java | 2 +-
.../stream/impl/OptionalInfoCalculator.java | 11 ++-
.../stream/internal/FlatteningLinStream.java | 4 +-
.../stream/internal/SurroundingLinStream.java | 10 +--
tree/build.gradle.kts | 4 +-
tree/src/main/java/module-info.java | 5 +-
.../linbus/tree/LinByteArrayTag.java | 21 +++--
.../org/enginehub/linbus/tree/LinByteTag.java | 13 ++-
.../enginehub/linbus/tree/LinCompoundTag.java | 84 ++++++++-----------
.../enginehub/linbus/tree/LinDoubleTag.java | 11 ++-
.../org/enginehub/linbus/tree/LinEndTag.java | 7 +-
.../enginehub/linbus/tree/LinFloatTag.java | 11 ++-
.../enginehub/linbus/tree/LinIntArrayTag.java | 17 ++--
.../org/enginehub/linbus/tree/LinIntTag.java | 11 ++-
.../org/enginehub/linbus/tree/LinListTag.java | 36 ++++----
.../linbus/tree/LinLongArrayTag.java | 19 ++---
.../org/enginehub/linbus/tree/LinLongTag.java | 11 ++-
.../enginehub/linbus/tree/LinRootEntry.java | 7 +-
.../enginehub/linbus/tree/LinShortTag.java | 11 ++-
.../enginehub/linbus/tree/LinStringTag.java | 13 ++-
.../org/enginehub/linbus/tree/LinTag.java | 10 +--
.../org/enginehub/linbus/tree/LinTagType.java | 63 +++++++-------
.../org/enginehub/linbus/tree/ToLinTag.java | 4 +-
.../linbus/tree/impl/LinTagReader.java | 13 ++-
.../enginehub/linbus/tree/TagTestUtil.java | 3 +-
.../linbus/tree/impl/package-info.java | 22 +++++
.../enginehub/linbus/tree/package-info.java | 22 +++++
.../linbus/tree/truth/LinTagSubject.java | 20 ++++-
.../linbus/tree/truth/package-info.java | 22 +++++
50 files changed, 409 insertions(+), 280 deletions(-)
create mode 100644 format-snbt/src/test/java/org/enginehub/linbus/format/snbt/impl/package-info.java
create mode 100644 format-snbt/src/test/java/org/enginehub/linbus/format/snbt/impl/reader/package-info.java
create mode 100644 format-snbt/src/test/java/org/enginehub/linbus/format/snbt/package-info.java
create mode 100644 format-snbt/src/test/java/org/enginehub/linbus/format/snbt/util/package-info.java
create mode 100644 tree/src/test/java/org/enginehub/linbus/tree/impl/package-info.java
create mode 100644 tree/src/test/java/org/enginehub/linbus/tree/package-info.java
create mode 100644 tree/src/test/java/org/enginehub/linbus/tree/truth/package-info.java
diff --git a/common/build.gradle.kts b/common/build.gradle.kts
index 742321a..d119c63 100644
--- a/common/build.gradle.kts
+++ b/common/build.gradle.kts
@@ -6,13 +6,13 @@ plugins {
}
dependencies {
- compileOnlyApi(libs.jetbrains.annotations)
+ compileOnlyApi(libs.jspecify.annotations)
testImplementation(platform(libs.junit.bom))
testImplementation(libs.junit.jupiter.api)
testRuntimeOnly(libs.junit.jupiter.engine)
- testImplementation(libs.truth.asProvider()) {
+ testImplementation(libs.truth) {
exclude(group = "junit")
}
}
diff --git a/common/src/main/java/module-info.java b/common/src/main/java/module-info.java
index 5a5688f..dab727b 100644
--- a/common/src/main/java/module-info.java
+++ b/common/src/main/java/module-info.java
@@ -16,12 +16,15 @@
* along with this program. If not, see .
*/
+import org.jspecify.annotations.NullMarked;
+
/**
* The common module of lin-bus, shared between the streaming and tree modules.
*/
+@NullMarked
module org.enginehub.linbus.common {
exports org.enginehub.linbus.common;
exports org.enginehub.linbus.common.internal to org.enginehub.linbus.stream, org.enginehub.linbus.tree,
org.enginehub.linbus.format.snbt;
- requires static org.jetbrains.annotations;
+ requires static transitive org.jspecify;
}
diff --git a/common/src/main/java/org/enginehub/linbus/common/IOFunction.java b/common/src/main/java/org/enginehub/linbus/common/IOFunction.java
index 5fbccfe..1815234 100644
--- a/common/src/main/java/org/enginehub/linbus/common/IOFunction.java
+++ b/common/src/main/java/org/enginehub/linbus/common/IOFunction.java
@@ -18,6 +18,8 @@
package org.enginehub.linbus.common;
+import org.jspecify.annotations.Nullable;
+
import java.io.IOException;
import java.util.function.Function;
@@ -27,7 +29,7 @@
* @param the input type
* @param the output type
*/
-public interface IOFunction {
+public interface IOFunction {
/**
* Applies this function to the given argument.
*
diff --git a/common/src/main/java/org/enginehub/linbus/common/internal/AbstractIterator.java b/common/src/main/java/org/enginehub/linbus/common/internal/AbstractIterator.java
index 365dafa..cae7353 100644
--- a/common/src/main/java/org/enginehub/linbus/common/internal/AbstractIterator.java
+++ b/common/src/main/java/org/enginehub/linbus/common/internal/AbstractIterator.java
@@ -18,7 +18,7 @@
package org.enginehub.linbus.common.internal;
-import org.jetbrains.annotations.Nullable;
+import org.jspecify.annotations.Nullable;
import java.util.Iterator;
import java.util.NoSuchElementException;
@@ -30,7 +30,7 @@
*
* @param the type of items returned by this iterator
*/
-public abstract class AbstractIterator implements Iterator {
+public abstract class AbstractIterator implements Iterator {
private boolean needNext = true;
private boolean end;
private T next;
diff --git a/format-snbt/build.gradle.kts b/format-snbt/build.gradle.kts
index ab45523..e52498d 100644
--- a/format-snbt/build.gradle.kts
+++ b/format-snbt/build.gradle.kts
@@ -6,7 +6,7 @@ plugins {
}
dependencies {
- compileOnlyApi(libs.jetbrains.annotations)
+ compileOnlyApi(libs.jspecify.annotations)
api(project(":common"))
api(project(":stream"))
@@ -17,7 +17,7 @@ dependencies {
testImplementation(libs.junit.jupiter.api)
testRuntimeOnly(libs.junit.jupiter.engine)
- testImplementation(libs.truth.asProvider()) {
+ testImplementation(libs.truth) {
exclude(group = "junit")
}
}
diff --git a/format-snbt/src/main/java/module-info.java b/format-snbt/src/main/java/module-info.java
index 53f2787..b16fb39 100644
--- a/format-snbt/src/main/java/module-info.java
+++ b/format-snbt/src/main/java/module-info.java
@@ -16,13 +16,16 @@
* along with this program. If not, see .
*/
+import org.jspecify.annotations.NullMarked;
+
/**
* The tree module of lin-bus. Presents a standard tree structure of NBT. Internally, everything is parsed using the
* streaming module.
*/
+@NullMarked
module org.enginehub.linbus.format.snbt {
exports org.enginehub.linbus.format.snbt;
- requires static transitive org.jetbrains.annotations;
+ requires static transitive org.jspecify;
requires transitive org.enginehub.linbus.common;
requires transitive org.enginehub.linbus.stream;
}
diff --git a/format-snbt/src/main/java/org/enginehub/linbus/format/snbt/LinStringIO.java b/format-snbt/src/main/java/org/enginehub/linbus/format/snbt/LinStringIO.java
index 960273f..4a41edd 100644
--- a/format-snbt/src/main/java/org/enginehub/linbus/format/snbt/LinStringIO.java
+++ b/format-snbt/src/main/java/org/enginehub/linbus/format/snbt/LinStringIO.java
@@ -24,7 +24,6 @@
import org.enginehub.linbus.format.snbt.impl.reader.LinSnbtTokenizer;
import org.enginehub.linbus.stream.LinStream;
import org.enginehub.linbus.stream.LinStreamable;
-import org.jetbrains.annotations.NotNull;
import java.io.IOException;
import java.io.Reader;
@@ -54,7 +53,7 @@ public class LinStringIO {
* @param input the input to read from
* @return the stream of NBT tokens
*/
- public static @NotNull LinStream read(@NotNull Reader input) {
+ public static LinStream read(Reader input) {
return new LinSnbtReader(new LinSnbtTokenizer(input));
}
@@ -64,7 +63,7 @@ public class LinStringIO {
* @param input the input to read from
* @return the stream of NBT tokens
*/
- public static @NotNull LinStream readFromString(@NotNull String input) {
+ public static LinStream readFromString(String input) {
return read(new StringReader(input));
}
@@ -86,7 +85,7 @@ public class LinStringIO {
* @return the result
* @throws IOException if an I/O error occurs
*/
- public static R readUsing(@NotNull Reader input, @NotNull IOFunction super @NotNull LinStream, R> transform) throws IOException {
+ public static R readUsing(Reader input, IOFunction super LinStream, R> transform) throws IOException {
return transform.apply(read(input));
}
@@ -98,7 +97,7 @@ public static R readUsing(@NotNull Reader input, @NotNull IOFunction super
* @param the type of the result
* @return the stream of NBT tokens
*/
- public static R readFromStringUsing(@NotNull String input, @NotNull IOFunction super @NotNull LinStream, R> transform) {
+ public static R readFromStringUsing(String input, IOFunction super LinStream, R> transform) {
try {
return transform.apply(readFromString(input));
} catch (IOException e) {
@@ -117,7 +116,7 @@ public static R readFromStringUsing(@NotNull String input, @NotNull IOFuncti
* @param tokens the stream of NBT tokens
* @throws IOException if an I/O error occurs
*/
- public static void write(@NotNull Appendable output, @NotNull LinStreamable tokens) throws IOException {
+ public static void write(Appendable output, LinStreamable tokens) throws IOException {
new LinSnbtWriter().write(output, tokens.linStream());
}
@@ -131,7 +130,7 @@ public static void write(@NotNull Appendable output, @NotNull LinStreamable toke
* @param tokens the stream of NBT tokens
* @return the string
*/
- public static String writeToString(@NotNull LinStreamable tokens) {
+ public static String writeToString(LinStreamable tokens) {
var builder = new StringBuilder();
try {
write(builder, tokens);
diff --git a/format-snbt/src/main/java/org/enginehub/linbus/format/snbt/impl/LinSnbtWriter.java b/format-snbt/src/main/java/org/enginehub/linbus/format/snbt/impl/LinSnbtWriter.java
index efa3ab3..c269cad 100644
--- a/format-snbt/src/main/java/org/enginehub/linbus/format/snbt/impl/LinSnbtWriter.java
+++ b/format-snbt/src/main/java/org/enginehub/linbus/format/snbt/impl/LinSnbtWriter.java
@@ -23,7 +23,6 @@
import org.enginehub.linbus.stream.LinStreamable;
import org.enginehub.linbus.stream.exception.NbtWriteException;
import org.enginehub.linbus.stream.token.LinToken;
-import org.jetbrains.annotations.NotNull;
import java.io.IOException;
import java.nio.ByteBuffer;
@@ -55,7 +54,7 @@ record WritingArray() implements WriteState {
* @param tokens the tokens
* @throws IOException if an I/O error occurs
*/
- public void write(@NotNull Appendable output, @NotNull LinStream tokens) throws IOException {
+ public void write(Appendable output, LinStream tokens) throws IOException {
while (true) {
var state = stateStack.peekLast();
LinToken token = tokens.nextOrNull();
diff --git a/format-snbt/src/main/java/org/enginehub/linbus/format/snbt/impl/reader/LinSnbtReader.java b/format-snbt/src/main/java/org/enginehub/linbus/format/snbt/impl/reader/LinSnbtReader.java
index 701fb08..e0a4c27 100644
--- a/format-snbt/src/main/java/org/enginehub/linbus/format/snbt/impl/reader/LinSnbtReader.java
+++ b/format-snbt/src/main/java/org/enginehub/linbus/format/snbt/impl/reader/LinSnbtReader.java
@@ -21,8 +21,7 @@
import org.enginehub.linbus.stream.LinStream;
import org.enginehub.linbus.stream.exception.NbtParseException;
import org.enginehub.linbus.stream.token.LinToken;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
+import org.jspecify.annotations.Nullable;
import java.io.DataInput;
import java.nio.Buffer;
@@ -114,7 +113,7 @@ record ReadValue(boolean mustBeCompound) implements State {
private static final int BUFFER_SIZE = 4096;
- private final Iterator extends @NotNull SnbtTokenWithMetadata> input;
+ private final Iterator extends SnbtTokenWithMetadata> input;
/**
* The state stack. We're currently on the one that's LAST.
*/
@@ -126,7 +125,7 @@ record ReadValue(boolean mustBeCompound) implements State {
/**
* The pushback token stack, which is used to push back tokens that we've read.
*/
- private final Deque<@NotNull SnbtTokenWithMetadata> readAgainStack;
+ private final Deque readAgainStack;
private int charIndex;
/**
@@ -134,14 +133,14 @@ record ReadValue(boolean mustBeCompound) implements State {
*
* @param input the input to read from
*/
- public LinSnbtReader(Iterator extends @NotNull SnbtTokenWithMetadata> input) {
+ public LinSnbtReader(Iterator extends SnbtTokenWithMetadata> input) {
this.input = input;
this.stateStack = new ArrayDeque<>(List.of(new State.ReadValue(true)));
this.tokenQueue = new ArrayDeque<>();
this.readAgainStack = new ArrayDeque<>();
}
- private @NotNull SnbtTokenWithMetadata read() {
+ private SnbtTokenWithMetadata read() {
var token = readAgainStack.pollFirst();
if (token != null) {
return token;
diff --git a/format-snbt/src/main/java/org/enginehub/linbus/format/snbt/impl/reader/LinSnbtTokenizer.java b/format-snbt/src/main/java/org/enginehub/linbus/format/snbt/impl/reader/LinSnbtTokenizer.java
index 3edf0d8..d4dfefe 100644
--- a/format-snbt/src/main/java/org/enginehub/linbus/format/snbt/impl/reader/LinSnbtTokenizer.java
+++ b/format-snbt/src/main/java/org/enginehub/linbus/format/snbt/impl/reader/LinSnbtTokenizer.java
@@ -22,7 +22,7 @@
import org.enginehub.linbus.format.snbt.impl.Elusion;
import org.enginehub.linbus.stream.exception.NbtParseException;
import org.enginehub.linbus.stream.token.LinToken;
-import org.jetbrains.annotations.NotNull;
+import org.jspecify.annotations.Nullable;
import java.io.BufferedReader;
import java.io.IOException;
@@ -32,7 +32,7 @@
/**
* But not like, a tokenizer into {@link LinToken}s. But like our own internal {@link SnbtToken}. Sigh.
*/
-public class LinSnbtTokenizer extends AbstractIterator<@NotNull SnbtTokenWithMetadata> {
+public class LinSnbtTokenizer extends AbstractIterator {
private final Reader input;
private int charIndex = -1;
private boolean eatAllWhitespaceAfter;
@@ -42,7 +42,7 @@ public class LinSnbtTokenizer extends AbstractIterator<@NotNull SnbtTokenWithMet
*
* @param input the input to read from
*/
- public LinSnbtTokenizer(@NotNull Reader input) {
+ public LinSnbtTokenizer(Reader input) {
this.input = input.markSupported() ? input : new BufferedReader(input);
}
@@ -67,7 +67,7 @@ private void skipWhitespace() throws IOException {
}
@Override
- protected SnbtTokenWithMetadata computeNext() {
+ protected @Nullable SnbtTokenWithMetadata computeNext() {
try {
skipWhitespace();
input.mark(1);
diff --git a/format-snbt/src/test/java/org/enginehub/linbus/format/snbt/impl/package-info.java b/format-snbt/src/test/java/org/enginehub/linbus/format/snbt/impl/package-info.java
new file mode 100644
index 0000000..27b5cf5
--- /dev/null
+++ b/format-snbt/src/test/java/org/enginehub/linbus/format/snbt/impl/package-info.java
@@ -0,0 +1,22 @@
+/*
+ * Copyright (c) EngineHub
+ * Copyright (c) contributors
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+@NullMarked
+package org.enginehub.linbus.format.snbt.impl;
+
+import org.jspecify.annotations.NullMarked;
diff --git a/format-snbt/src/test/java/org/enginehub/linbus/format/snbt/impl/reader/package-info.java b/format-snbt/src/test/java/org/enginehub/linbus/format/snbt/impl/reader/package-info.java
new file mode 100644
index 0000000..5d31e8a
--- /dev/null
+++ b/format-snbt/src/test/java/org/enginehub/linbus/format/snbt/impl/reader/package-info.java
@@ -0,0 +1,22 @@
+/*
+ * Copyright (c) EngineHub
+ * Copyright (c) contributors
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+@NullMarked
+package org.enginehub.linbus.format.snbt.impl.reader;
+
+import org.jspecify.annotations.NullMarked;
diff --git a/format-snbt/src/test/java/org/enginehub/linbus/format/snbt/package-info.java b/format-snbt/src/test/java/org/enginehub/linbus/format/snbt/package-info.java
new file mode 100644
index 0000000..58eb193
--- /dev/null
+++ b/format-snbt/src/test/java/org/enginehub/linbus/format/snbt/package-info.java
@@ -0,0 +1,22 @@
+/*
+ * Copyright (c) EngineHub
+ * Copyright (c) contributors
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+@NullMarked
+package org.enginehub.linbus.format.snbt;
+
+import org.jspecify.annotations.NullMarked;
diff --git a/format-snbt/src/test/java/org/enginehub/linbus/format/snbt/util/TracedReader.java b/format-snbt/src/test/java/org/enginehub/linbus/format/snbt/util/TracedReader.java
index 67ae0e1..c93bcee 100644
--- a/format-snbt/src/test/java/org/enginehub/linbus/format/snbt/util/TracedReader.java
+++ b/format-snbt/src/test/java/org/enginehub/linbus/format/snbt/util/TracedReader.java
@@ -18,8 +18,6 @@
package org.enginehub.linbus.format.snbt.util;
-import org.jetbrains.annotations.NotNull;
-
import java.io.IOException;
import java.io.Reader;
import java.io.Writer;
@@ -55,7 +53,7 @@ private boolean isRelevantStackFrame(StackWalker.StackFrame frame) {
}
@Override
- public int read(@NotNull CharBuffer target) throws IOException {
+ public int read(CharBuffer target) throws IOException {
int result = delegate.read(target);
System.err.println("read(" + target + "): " + result);
printRelevantStack();
@@ -75,7 +73,7 @@ public int read() throws IOException {
}
@Override
- public int read(char @NotNull [] cbuf) throws IOException {
+ public int read(char[] cbuf) throws IOException {
int result = delegate.read(cbuf);
System.err.println("read(char[].length = " + cbuf.length + "): " + result);
printRelevantStack();
@@ -83,7 +81,7 @@ public int read(char @NotNull [] cbuf) throws IOException {
}
@Override
- public int read(char @NotNull [] cbuf, int off, int len) throws IOException {
+ public int read(char[] cbuf, int off, int len) throws IOException {
int result = delegate.read(cbuf, off, len);
System.err.println("read(char[].length = " + cbuf.length + ", off = " + off + ", len = " + len + "): " + result);
printRelevantStack();
diff --git a/format-snbt/src/test/java/org/enginehub/linbus/format/snbt/util/package-info.java b/format-snbt/src/test/java/org/enginehub/linbus/format/snbt/util/package-info.java
new file mode 100644
index 0000000..64f58e7
--- /dev/null
+++ b/format-snbt/src/test/java/org/enginehub/linbus/format/snbt/util/package-info.java
@@ -0,0 +1,22 @@
+/*
+ * Copyright (c) EngineHub
+ * Copyright (c) contributors
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+@NullMarked
+package org.enginehub.linbus.format.snbt.util;
+
+import org.jspecify.annotations.NullMarked;
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index 733622f..638e7ce 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -1,13 +1,7 @@
-[versions]
-truth = "1.4.2"
-
[libraries]
-jetbrains-annotations = "org.jetbrains:annotations:24.1.0"
+jspecify-annotations = "org.jspecify:jspecify:0.3.0"
guava = "com.google.guava:guava:31.0.1-jre"
junit-bom = "org.junit:junit-bom:5.10.2"
junit-jupiter-api.module = "org.junit.jupiter:junit-jupiter-api"
junit-jupiter-engine.module = "org.junit.jupiter:junit-jupiter-engine"
-truth.module = "com.google.truth:truth"
-truth.version.ref = "truth"
-truth-extensions-java8.module = "com.google.truth.extensions:truth-java8-extension"
-truth-extensions-java8.version.ref = "truth"
+truth = "com.google.truth:truth:1.4.2"
diff --git a/stream/build.gradle.kts b/stream/build.gradle.kts
index 384e0b8..a319030 100644
--- a/stream/build.gradle.kts
+++ b/stream/build.gradle.kts
@@ -6,7 +6,7 @@ plugins {
}
dependencies {
- compileOnlyApi(libs.jetbrains.annotations)
+ compileOnlyApi(libs.jspecify.annotations)
api(project(":common"))
@@ -14,10 +14,7 @@ dependencies {
testImplementation(libs.junit.jupiter.api)
testRuntimeOnly(libs.junit.jupiter.engine)
- testImplementation(libs.truth.asProvider()) {
- exclude(group = "junit")
- }
- testImplementation(libs.truth.extensions.java8) {
+ testImplementation(libs.truth) {
exclude(group = "junit")
}
}
diff --git a/stream/src/main/java/module-info.java b/stream/src/main/java/module-info.java
index 3e41e3f..c6deab8 100644
--- a/stream/src/main/java/module-info.java
+++ b/stream/src/main/java/module-info.java
@@ -16,14 +16,17 @@
* along with this program. If not, see .
*/
+import org.jspecify.annotations.NullMarked;
+
/**
* The streaming module of lin-bus. Features a Jackson-like API for decoding and encoding NBT.
*/
+@NullMarked
module org.enginehub.linbus.stream {
exports org.enginehub.linbus.stream;
exports org.enginehub.linbus.stream.exception;
exports org.enginehub.linbus.stream.token;
exports org.enginehub.linbus.stream.internal to org.enginehub.linbus.tree;
- requires static transitive org.jetbrains.annotations;
+ requires static transitive org.jspecify;
requires transitive org.enginehub.linbus.common;
}
diff --git a/stream/src/main/java/org/enginehub/linbus/stream/LinBinaryIO.java b/stream/src/main/java/org/enginehub/linbus/stream/LinBinaryIO.java
index cfc41f9..d56076c 100644
--- a/stream/src/main/java/org/enginehub/linbus/stream/LinBinaryIO.java
+++ b/stream/src/main/java/org/enginehub/linbus/stream/LinBinaryIO.java
@@ -23,7 +23,7 @@
import org.enginehub.linbus.stream.exception.NbtWriteException;
import org.enginehub.linbus.stream.impl.LinNbtReader;
import org.enginehub.linbus.stream.token.LinToken;
-import org.jetbrains.annotations.NotNull;
+import org.jspecify.annotations.Nullable;
import java.io.DataInput;
import java.io.DataOutput;
@@ -46,7 +46,7 @@ public class LinBinaryIO {
* @param input the input to read from
* @return the stream of NBT tokens
*/
- public static LinStream read(@NotNull DataInput input) {
+ public static LinStream read(DataInput input) {
return new LinNbtReader(input);
}
@@ -63,7 +63,7 @@ public static LinStream read(@NotNull DataInput input) {
* @return the result
* @throws IOException if an I/O error occurs ({@link UncheckedIOException} is unwrapped)
*/
- public static R readUsing(@NotNull DataInput input, @NotNull IOFunction super LinStream, ? extends R> transform)
+ public static R readUsing(DataInput input, IOFunction super LinStream, ? extends R> transform)
throws IOException {
return transform.apply(read(input));
}
@@ -84,7 +84,7 @@ public static R readUsing(@NotNull DataInput input, @NotNull IOFunction su
* @param tokens the stream of NBT tokens
* @throws IOException if an I/O error occurs
*/
- public static void write(@NotNull DataOutput output, @NotNull LinStreamable tokens) throws IOException {
+ public static void write(DataOutput output, LinStreamable tokens) throws IOException {
// This is essentially free if the info is already there, so we can just do it.
LinStream tokenStream = tokens.linStream().calculateOptionalInfo();
boolean seenFirstName = false;
@@ -193,7 +193,7 @@ public static void write(@NotNull DataOutput output, @NotNull LinStreamable toke
}
}
- private static void writeIdAndNameIfNeeded(DataOutput output, LinTagId id, String name) throws IOException {
+ private static void writeIdAndNameIfNeeded(DataOutput output, LinTagId id, @Nullable String name) throws IOException {
if (name != null) {
output.writeByte(id.id());
output.writeUTF(name);
diff --git a/stream/src/main/java/org/enginehub/linbus/stream/LinStream.java b/stream/src/main/java/org/enginehub/linbus/stream/LinStream.java
index ef22639..dfa4488 100644
--- a/stream/src/main/java/org/enginehub/linbus/stream/LinStream.java
+++ b/stream/src/main/java/org/enginehub/linbus/stream/LinStream.java
@@ -21,8 +21,7 @@
import org.enginehub.linbus.common.internal.AbstractIterator;
import org.enginehub.linbus.stream.impl.OptionalInfoCalculator;
import org.enginehub.linbus.stream.token.LinToken;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
+import org.jspecify.annotations.Nullable;
import java.io.IOException;
import java.io.UncheckedIOException;
@@ -47,7 +46,7 @@ static LinStream of() {
*/
static LinStream of(LinToken token) {
return new LinStream() {
- private LinToken nextToken = token;
+ private @Nullable LinToken nextToken = token;
@Override
public @Nullable LinToken nextOrNull() {
@@ -122,7 +121,7 @@ default LinStream calculateOptionalInfo() {
* @return this
*/
@Override
- default @NotNull LinStream linStream() {
+ default LinStream linStream() {
return this;
}
@@ -135,7 +134,7 @@ default LinStream calculateOptionalInfo() {
*
* @return an iterator over this stream
*/
- default @NotNull Iterator asIterator() {
+ default Iterator asIterator() {
return new AbstractIterator<>() {
@Override
protected @Nullable LinToken computeNext() {
diff --git a/stream/src/main/java/org/enginehub/linbus/stream/LinStreamable.java b/stream/src/main/java/org/enginehub/linbus/stream/LinStreamable.java
index 62bfbbe..0bfad0a 100644
--- a/stream/src/main/java/org/enginehub/linbus/stream/LinStreamable.java
+++ b/stream/src/main/java/org/enginehub/linbus/stream/LinStreamable.java
@@ -18,8 +18,6 @@
package org.enginehub.linbus.stream;
-import org.jetbrains.annotations.NotNull;
-
/**
* Represents something that can provide a {@link LinStream}.
*/
@@ -27,5 +25,5 @@ public interface LinStreamable {
/**
* {@return a {@link LinStream} for this object}
*/
- @NotNull LinStream linStream();
+ LinStream linStream();
}
diff --git a/stream/src/main/java/org/enginehub/linbus/stream/impl/LinNbtReader.java b/stream/src/main/java/org/enginehub/linbus/stream/impl/LinNbtReader.java
index ca67795..0ec0c2e 100644
--- a/stream/src/main/java/org/enginehub/linbus/stream/impl/LinNbtReader.java
+++ b/stream/src/main/java/org/enginehub/linbus/stream/impl/LinNbtReader.java
@@ -22,7 +22,7 @@
import org.enginehub.linbus.stream.LinStream;
import org.enginehub.linbus.stream.exception.NbtParseException;
import org.enginehub.linbus.stream.token.LinToken;
-import org.jetbrains.annotations.Nullable;
+import org.jspecify.annotations.Nullable;
import java.io.DataInput;
import java.io.IOException;
diff --git a/stream/src/main/java/org/enginehub/linbus/stream/impl/OptionalInfoCalculator.java b/stream/src/main/java/org/enginehub/linbus/stream/impl/OptionalInfoCalculator.java
index 78db59c..6b8d458 100644
--- a/stream/src/main/java/org/enginehub/linbus/stream/impl/OptionalInfoCalculator.java
+++ b/stream/src/main/java/org/enginehub/linbus/stream/impl/OptionalInfoCalculator.java
@@ -22,8 +22,7 @@
import org.enginehub.linbus.stream.LinStream;
import org.enginehub.linbus.stream.exception.NbtParseException;
import org.enginehub.linbus.stream.token.LinToken;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
+import org.jspecify.annotations.Nullable;
import java.io.IOException;
import java.util.ArrayDeque;
@@ -43,7 +42,7 @@ private interface OptionalFill {
}
private final LinStream original;
- private Deque tokenBuffer;
+ private @Nullable Deque tokenBuffer;
/**
* Create a new {@link OptionalInfoCalculator}.
@@ -81,7 +80,7 @@ public LinStream calculateOptionalInfo() {
return this;
}
- private record TokenAndBuffer(@NotNull LinToken token, @Nullable Deque buffer) {
+ private record TokenAndBuffer(LinToken token, @Nullable Deque buffer) {
}
private TokenAndBuffer fillIfNeeded(LinToken token) throws IOException {
@@ -134,8 +133,8 @@ private TokenAndBuffer getFilled(OptionalFill fill) throws IOException {
private static final class ListStartFill implements OptionalFill {
private final int knownSize;
- private final ValueCounter counter;
- private LinTagId elementId;
+ private final @Nullable ValueCounter counter;
+ private @Nullable LinTagId elementId;
public ListStartFill(LinToken.ListStart listStart) {
if (listStart.size().isPresent()) {
diff --git a/stream/src/main/java/org/enginehub/linbus/stream/internal/FlatteningLinStream.java b/stream/src/main/java/org/enginehub/linbus/stream/internal/FlatteningLinStream.java
index e881b8c..d44eab2 100644
--- a/stream/src/main/java/org/enginehub/linbus/stream/internal/FlatteningLinStream.java
+++ b/stream/src/main/java/org/enginehub/linbus/stream/internal/FlatteningLinStream.java
@@ -21,7 +21,7 @@
import org.enginehub.linbus.stream.LinStream;
import org.enginehub.linbus.stream.LinStreamable;
import org.enginehub.linbus.stream.token.LinToken;
-import org.jetbrains.annotations.Nullable;
+import org.jspecify.annotations.Nullable;
import java.io.IOException;
import java.util.Iterator;
@@ -31,7 +31,7 @@
*/
public class FlatteningLinStream implements LinStream {
private final Iterator extends LinStreamable> streamables;
- private LinStream current;
+ private @Nullable LinStream current;
/**
* Create a new flattening stream.
diff --git a/stream/src/main/java/org/enginehub/linbus/stream/internal/SurroundingLinStream.java b/stream/src/main/java/org/enginehub/linbus/stream/internal/SurroundingLinStream.java
index 0251815..3a513f4 100644
--- a/stream/src/main/java/org/enginehub/linbus/stream/internal/SurroundingLinStream.java
+++ b/stream/src/main/java/org/enginehub/linbus/stream/internal/SurroundingLinStream.java
@@ -20,7 +20,7 @@
import org.enginehub.linbus.stream.LinStream;
import org.enginehub.linbus.stream.token.LinToken;
-import org.jetbrains.annotations.Nullable;
+import org.jspecify.annotations.Nullable;
import java.io.IOException;
@@ -28,9 +28,9 @@
* A {@link LinStream} that wraps another {@link LinStream} and adds a token to the beginning and end of the stream.
*/
public class SurroundingLinStream implements LinStream {
- private LinToken prefix;
- private LinStream stream;
- private LinToken suffix;
+ private @Nullable LinToken prefix;
+ private @Nullable LinStream stream;
+ private @Nullable LinToken suffix;
/**
* Creates a new {@link SurroundingLinStream} with the given prefix and suffix.
@@ -39,7 +39,7 @@ public class SurroundingLinStream implements LinStream {
* @param stream the stream to wrap
* @param suffix the suffix token, may be null
*/
- public SurroundingLinStream(LinToken prefix, LinStream stream, LinToken suffix) {
+ public SurroundingLinStream(@Nullable LinToken prefix, LinStream stream, @Nullable LinToken suffix) {
this.prefix = prefix;
this.stream = stream;
this.suffix = suffix;
diff --git a/tree/build.gradle.kts b/tree/build.gradle.kts
index 3f029a9..9fd3436 100644
--- a/tree/build.gradle.kts
+++ b/tree/build.gradle.kts
@@ -6,7 +6,7 @@ plugins {
}
dependencies {
- compileOnlyApi(libs.jetbrains.annotations)
+ compileOnlyApi(libs.jspecify.annotations)
api(project(":common"))
api(project(":stream"))
@@ -15,7 +15,7 @@ dependencies {
testImplementation(libs.junit.jupiter.api)
testRuntimeOnly(libs.junit.jupiter.engine)
- testImplementation(libs.truth.asProvider()) {
+ testImplementation(libs.truth) {
exclude(group = "junit")
}
}
diff --git a/tree/src/main/java/module-info.java b/tree/src/main/java/module-info.java
index 3864262..d8f11e8 100644
--- a/tree/src/main/java/module-info.java
+++ b/tree/src/main/java/module-info.java
@@ -16,13 +16,16 @@
* along with this program. If not, see .
*/
+import org.jspecify.annotations.NullMarked;
+
/**
* The tree module of lin-bus. Presents a standard tree structure of NBT. Internally, everything is parsed using the
* streaming module.
*/
+@NullMarked
module org.enginehub.linbus.tree {
exports org.enginehub.linbus.tree;
- requires static transitive org.jetbrains.annotations;
+ requires static transitive org.jspecify;
requires transitive org.enginehub.linbus.common;
requires transitive org.enginehub.linbus.stream;
}
diff --git a/tree/src/main/java/org/enginehub/linbus/tree/LinByteArrayTag.java b/tree/src/main/java/org/enginehub/linbus/tree/LinByteArrayTag.java
index 423806e..cbd09f0 100644
--- a/tree/src/main/java/org/enginehub/linbus/tree/LinByteArrayTag.java
+++ b/tree/src/main/java/org/enginehub/linbus/tree/LinByteArrayTag.java
@@ -21,8 +21,7 @@
import org.enginehub.linbus.stream.LinStream;
import org.enginehub.linbus.stream.internal.SurroundingLinStream;
import org.enginehub.linbus.stream.token.LinToken;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
+import org.jspecify.annotations.Nullable;
import java.nio.ByteBuffer;
import java.util.Arrays;
@@ -30,30 +29,30 @@
/**
* Represents a byte array tag.
*/
-public final class LinByteArrayTag extends LinTag {
+public final class LinByteArrayTag extends LinTag {
/**
* Creates a new byte array tag from the given byte array. The array will be {@linkplain Object#clone() cloned}.
*
* @param value the value
* @return the tag
*/
- public static @NotNull LinByteArrayTag of(byte @NotNull ... value) {
+ public static LinByteArrayTag of(byte... value) {
return new LinByteArrayTag(value.clone());
}
private final byte[] value;
- private LinByteArrayTag(byte @NotNull [] value) {
+ private LinByteArrayTag(byte[] value) {
this.value = value;
}
@Override
- public @NotNull LinTagType<@NotNull LinByteArrayTag> type() {
+ public LinTagType type() {
return LinTagType.byteArrayTag();
}
@Override
- public byte @NotNull [] value() {
+ public byte[] value() {
return value.clone();
}
@@ -63,12 +62,12 @@ private LinByteArrayTag(byte @NotNull [] value) {
*
* @return a read-only {@link ByteBuffer} providing view access to the contents of this tag
*/
- public @NotNull ByteBuffer view() {
+ public ByteBuffer view() {
return ByteBuffer.wrap(value).asReadOnlyBuffer();
}
@Override
- public @NotNull LinStream linStream() {
+ public LinStream linStream() {
return new SurroundingLinStream(
new LinToken.ByteArrayStart(value.length),
new LinStream() {
@@ -91,7 +90,7 @@ private LinByteArrayTag(byte @NotNull [] value) {
}
@Override
- public boolean equals(Object o) {
+ public boolean equals(@Nullable Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
LinByteArrayTag that = (LinByteArrayTag) o;
@@ -106,7 +105,7 @@ public int hashCode() {
}
@Override
- public @NotNull String toString() {
+ public String toString() {
return getClass().getSimpleName() + Arrays.toString(value());
}
}
diff --git a/tree/src/main/java/org/enginehub/linbus/tree/LinByteTag.java b/tree/src/main/java/org/enginehub/linbus/tree/LinByteTag.java
index 1399e5d..8546715 100644
--- a/tree/src/main/java/org/enginehub/linbus/tree/LinByteTag.java
+++ b/tree/src/main/java/org/enginehub/linbus/tree/LinByteTag.java
@@ -20,12 +20,11 @@
import org.enginehub.linbus.stream.LinStream;
import org.enginehub.linbus.stream.token.LinToken;
-import org.jetbrains.annotations.NotNull;
/**
* Represents a byte tag.
*/
-public final class LinByteTag extends LinNumberTag<@NotNull Byte> {
+public final class LinByteTag extends LinNumberTag {
/**
* Creates a new byte tag from the given integer, which will be cast to a byte.
@@ -33,7 +32,7 @@ public final class LinByteTag extends LinNumberTag<@NotNull Byte> {
* @param value the value
* @return the tag
*/
- public static @NotNull LinByteTag fromInt(int value) {
+ public static LinByteTag fromInt(int value) {
return of((byte) value);
}
@@ -43,7 +42,7 @@ public final class LinByteTag extends LinNumberTag<@NotNull Byte> {
* @param value the value
* @return the tag
*/
- public static @NotNull LinByteTag of(byte value) {
+ public static LinByteTag of(byte value) {
return new LinByteTag(value);
}
@@ -54,12 +53,12 @@ private LinByteTag(byte value) {
}
@Override
- public @NotNull LinTagType<@NotNull LinByteTag> type() {
+ public LinTagType type() {
return LinTagType.byteTag();
}
@Override
- public @NotNull Byte value() {
+ public Byte value() {
return value;
}
@@ -73,7 +72,7 @@ public byte valueAsByte() {
}
@Override
- public @NotNull LinStream linStream() {
+ public LinStream linStream() {
return LinStream.of(new LinToken.Byte(value));
}
}
diff --git a/tree/src/main/java/org/enginehub/linbus/tree/LinCompoundTag.java b/tree/src/main/java/org/enginehub/linbus/tree/LinCompoundTag.java
index 64ac2ce..ec86807 100644
--- a/tree/src/main/java/org/enginehub/linbus/tree/LinCompoundTag.java
+++ b/tree/src/main/java/org/enginehub/linbus/tree/LinCompoundTag.java
@@ -25,9 +25,7 @@
import org.enginehub.linbus.stream.internal.SurroundingLinStream;
import org.enginehub.linbus.stream.token.LinToken;
import org.enginehub.linbus.tree.impl.LinTagReader;
-import org.jetbrains.annotations.Contract;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
+import org.jspecify.annotations.Nullable;
import java.io.IOException;
import java.util.Collections;
@@ -40,7 +38,7 @@
/**
* Represents a compound tag.
*/
-public final class LinCompoundTag extends LinTag<@NotNull Map<@NotNull String, ? extends @NotNull LinTag>>> {
+public final class LinCompoundTag extends LinTag
*/
-public final class LinTagType> {
- private static final LinTagType<@NotNull LinEndTag> END_TAG = new LinTagType<>(
+public final class LinTagType> {
+ private static final LinTagType END_TAG = new LinTagType<>(
LinTagId.END, LinEndTag.class
);
/**
* {@return the {@link LinTagType} for the end tag}
*/
- public static @NotNull LinTagType<@NotNull LinEndTag> endTag() {
+ public static LinTagType endTag() {
return END_TAG;
}
- private static final LinTagType<@NotNull LinByteTag> BYTE_TAG = new LinTagType<>(
+ private static final LinTagType BYTE_TAG = new LinTagType<>(
LinTagId.BYTE, LinByteTag.class
);
/**
* {@return the {@link LinTagType} for the byte tag}
*/
- public static @NotNull LinTagType<@NotNull LinByteTag> byteTag() {
+ public static LinTagType byteTag() {
return BYTE_TAG;
}
- private static final LinTagType<@NotNull LinShortTag> SHORT_TAG = new LinTagType<>(
+ private static final LinTagType SHORT_TAG = new LinTagType<>(
LinTagId.SHORT, LinShortTag.class
);
/**
* {@return the {@link LinTagType} for the short tag}
*/
- public static @NotNull LinTagType<@NotNull LinShortTag> shortTag() {
+ public static LinTagType shortTag() {
return SHORT_TAG;
}
- private static final LinTagType<@NotNull LinIntTag> INT_TAG = new LinTagType<>(
+ private static final LinTagType INT_TAG = new LinTagType<>(
LinTagId.INT, LinIntTag.class
);
/**
* {@return the {@link LinTagType} for the int tag}
*/
- public static @NotNull LinTagType<@NotNull LinIntTag> intTag() {
+ public static LinTagType intTag() {
return INT_TAG;
}
- private static final LinTagType<@NotNull LinLongTag> LONG_TAG = new LinTagType<>(
+ private static final LinTagType LONG_TAG = new LinTagType<>(
LinTagId.LONG, LinLongTag.class
);
/**
* {@return the {@link LinTagType} for the long tag}
*/
- public static @NotNull LinTagType<@NotNull LinLongTag> longTag() {
+ public static LinTagType longTag() {
return LONG_TAG;
}
- private static final LinTagType<@NotNull LinFloatTag> FLOAT_TAG = new LinTagType<>(
+ private static final LinTagType FLOAT_TAG = new LinTagType<>(
LinTagId.FLOAT, LinFloatTag.class
);
/**
* {@return the {@link LinTagType} for the float tag}
*/
- public static @NotNull LinTagType<@NotNull LinFloatTag> floatTag() {
+ public static LinTagType floatTag() {
return FLOAT_TAG;
}
- private static final LinTagType<@NotNull LinDoubleTag> DOUBLE_TAG = new LinTagType<>(
+ private static final LinTagType DOUBLE_TAG = new LinTagType<>(
LinTagId.DOUBLE, LinDoubleTag.class
);
/**
* {@return the {@link LinTagType} for the double tag}
*/
- public static @NotNull LinTagType<@NotNull LinDoubleTag> doubleTag() {
+ public static LinTagType doubleTag() {
return DOUBLE_TAG;
}
- private static final LinTagType<@NotNull LinByteArrayTag> BYTE_ARRAY_TAG = new LinTagType<>(
+ private static final LinTagType BYTE_ARRAY_TAG = new LinTagType<>(
LinTagId.BYTE_ARRAY, LinByteArrayTag.class
);
/**
* {@return the {@link LinTagType} for the byte array tag}
*/
- public static @NotNull LinTagType<@NotNull LinByteArrayTag> byteArrayTag() {
+ public static LinTagType byteArrayTag() {
return BYTE_ARRAY_TAG;
}
- private static final LinTagType<@NotNull LinStringTag> STRING_TAG = new LinTagType<>(
+ private static final LinTagType STRING_TAG = new LinTagType<>(
LinTagId.STRING, LinStringTag.class
);
/**
* {@return the {@link LinTagType} for the string tag}
*/
- public static @NotNull LinTagType<@NotNull LinStringTag> stringTag() {
+ public static LinTagType stringTag() {
return STRING_TAG;
}
@@ -141,47 +140,47 @@ public final class LinTagType> {
*
* @param the type of the list elements
*/
- public static > @NotNull LinTagType<@NotNull LinListTag> listTag() {
+ public static > LinTagType> listTag() {
@SuppressWarnings("unchecked")
- var cast = (LinTagType<@NotNull LinListTag>) LIST_TAG;
+ var cast = (LinTagType>) LIST_TAG;
return cast;
}
- private static final LinTagType<@NotNull LinCompoundTag> COMPOUND_TAG = new LinTagType<>(
+ private static final LinTagType COMPOUND_TAG = new LinTagType<>(
LinTagId.COMPOUND, LinCompoundTag.class
);
/**
* {@return the {@link LinTagType} for the compound tag}
*/
- public static @NotNull LinTagType<@NotNull LinCompoundTag> compoundTag() {
+ public static LinTagType compoundTag() {
return COMPOUND_TAG;
}
- private static final LinTagType<@NotNull LinIntArrayTag> INT_ARRAY_TAG = new LinTagType<>(
+ private static final LinTagType INT_ARRAY_TAG = new LinTagType<>(
LinTagId.INT_ARRAY, LinIntArrayTag.class
);
/**
* {@return the {@link LinTagType} for the int array tag}
*/
- public static @NotNull LinTagType<@NotNull LinIntArrayTag> intArrayTag() {
+ public static LinTagType intArrayTag() {
return INT_ARRAY_TAG;
}
- private static final LinTagType<@NotNull LinLongArrayTag> LONG_ARRAY_TAG = new LinTagType<>(
+ private static final LinTagType LONG_ARRAY_TAG = new LinTagType<>(
LinTagId.LONG_ARRAY, LinLongArrayTag.class
);
/**
* {@return the {@link LinTagType} for the long array tag}
*/
- public static @NotNull LinTagType<@NotNull LinLongArrayTag> longArrayTag() {
+ public static LinTagType longArrayTag() {
return LONG_ARRAY_TAG;
}
@SuppressWarnings("rawtypes")
- private static final @NotNull LinTagType>[] LIN_TAG_TYPES =
+ private static final LinTagType>[] LIN_TAG_TYPES =
Stream.of(
END_TAG,
BYTE_TAG,
@@ -207,7 +206,7 @@ public final class LinTagType> {
* @param the type of the tag
* @return the {@link LinTagType} for the given {@link LinTagId}
*/
- public static > @NotNull LinTagType fromId(LinTagId id) {
+ public static > LinTagType fromId(LinTagId id) {
@SuppressWarnings("unchecked")
var cast = (LinTagType) LIN_TAG_TYPES[id.id()];
return cast;
@@ -224,14 +223,14 @@ private LinTagType(LinTagId id, Class javaType) {
/**
* {@return the name of this tag type}
*/
- public @NotNull String name() {
+ public String name() {
return id.name();
}
/**
* {@return the id of this tag type}
*/
- public @NotNull LinTagId id() {
+ public LinTagId id() {
return id;
}
diff --git a/tree/src/main/java/org/enginehub/linbus/tree/ToLinTag.java b/tree/src/main/java/org/enginehub/linbus/tree/ToLinTag.java
index 4575036..cb091b7 100644
--- a/tree/src/main/java/org/enginehub/linbus/tree/ToLinTag.java
+++ b/tree/src/main/java/org/enginehub/linbus/tree/ToLinTag.java
@@ -18,8 +18,6 @@
package org.enginehub.linbus.tree;
-import org.jetbrains.annotations.NotNull;
-
/**
* Interface for things that can be converted to a {@link LinTag}.
*
@@ -31,5 +29,5 @@ public interface ToLinTag> {
*
* @return the {@link LinTag}
*/
- @NotNull T toLinTag();
+ T toLinTag();
}
diff --git a/tree/src/main/java/org/enginehub/linbus/tree/impl/LinTagReader.java b/tree/src/main/java/org/enginehub/linbus/tree/impl/LinTagReader.java
index b6f804e..46fab71 100644
--- a/tree/src/main/java/org/enginehub/linbus/tree/impl/LinTagReader.java
+++ b/tree/src/main/java/org/enginehub/linbus/tree/impl/LinTagReader.java
@@ -38,8 +38,7 @@
import org.enginehub.linbus.tree.LinStringTag;
import org.enginehub.linbus.tree.LinTag;
import org.enginehub.linbus.tree.LinTagType;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
+import org.jspecify.annotations.Nullable;
import java.io.IOException;
import java.nio.ByteBuffer;
@@ -61,7 +60,7 @@ public class LinTagReader {
* @return the root entry
* @throws IOException if an I/O error occurs
*/
- public static LinRootEntry readRoot(@NotNull LinStream tokens) throws IOException {
+ public static LinRootEntry readRoot(LinStream tokens) throws IOException {
tokens = tokens.calculateOptionalInfo();
if (!(tokens.nextOrNull() instanceof LinToken.Name name)) {
throw new NbtParseException("Expected root name");
@@ -84,7 +83,7 @@ public static LinRootEntry readRoot(@NotNull LinStream tokens) throws IOExceptio
* @return the compound tag
* @throws IOException if an I/O error occurs
*/
- public static LinCompoundTag readCompound(@NotNull LinStream tokens) throws IOException {
+ public static LinCompoundTag readCompound(LinStream tokens) throws IOException {
tokens = tokens.calculateOptionalInfo();
if (!(tokens.nextOrNull() instanceof LinToken.CompoundStart)) {
throw new NbtParseException("Expected compound start");
@@ -179,7 +178,7 @@ private static LinLongArrayTag readLongArray(LinStream tokens) throws IOExceptio
throw new NbtParseException("Expected long array end");
}
- private static > LinListTag readList(LinStream tokens) throws IOException {
+ private static > LinListTag readList(LinStream tokens) throws IOException {
if (!(tokens.nextOrNull() instanceof LinToken.ListStart start)) {
throw new NbtParseException("Expected list start");
}
@@ -195,7 +194,7 @@ private static LinLongArrayTag readLongArray(LinStream tokens) throws IOExceptio
return builder.build();
}
- private static > T readValue(@NotNull LinStream tokens, @Nullable LinTagType id) throws IOException {
+ private static > T readValue(LinStream tokens, @Nullable LinTagType id) throws IOException {
if (id == null) {
var next = tokens.nextOrNull();
if (next == null) {
@@ -221,7 +220,7 @@ private static LinLongArrayTag readLongArray(LinStream tokens) throws IOExceptio
});
}
- private static LinToken requireNextToken(@NotNull LinStream tokens) throws IOException {
+ private static LinToken requireNextToken(LinStream tokens) throws IOException {
LinToken linToken = tokens.nextOrNull();
if (linToken == null) {
throw new NbtParseException("Unexpected end of stream");
diff --git a/tree/src/test/java/org/enginehub/linbus/tree/TagTestUtil.java b/tree/src/test/java/org/enginehub/linbus/tree/TagTestUtil.java
index e7f8a6b..3c62b92 100644
--- a/tree/src/test/java/org/enginehub/linbus/tree/TagTestUtil.java
+++ b/tree/src/test/java/org/enginehub/linbus/tree/TagTestUtil.java
@@ -21,7 +21,6 @@
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
import org.enginehub.linbus.stream.LinBinaryIO;
-import org.jetbrains.annotations.NotNull;
import java.io.IOException;
import java.util.Map;
@@ -31,7 +30,7 @@
class TagTestUtil {
private static final String NESTING_KEY = "inner";
- static > void assertRoundTrip(T input) throws IOException {
+ static > void assertRoundTrip(T input) throws IOException {
ByteArrayDataOutput dataOutput = ByteStreams.newDataOutput();
// It's not legal to use bare streams, so we wrap in a root entry and compound.
LinBinaryIO.write(
diff --git a/tree/src/test/java/org/enginehub/linbus/tree/impl/package-info.java b/tree/src/test/java/org/enginehub/linbus/tree/impl/package-info.java
new file mode 100644
index 0000000..32d941e
--- /dev/null
+++ b/tree/src/test/java/org/enginehub/linbus/tree/impl/package-info.java
@@ -0,0 +1,22 @@
+/*
+ * Copyright (c) EngineHub
+ * Copyright (c) contributors
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+@NullMarked
+package org.enginehub.linbus.tree.impl;
+
+import org.jspecify.annotations.NullMarked;
diff --git a/tree/src/test/java/org/enginehub/linbus/tree/package-info.java b/tree/src/test/java/org/enginehub/linbus/tree/package-info.java
new file mode 100644
index 0000000..3df33e5
--- /dev/null
+++ b/tree/src/test/java/org/enginehub/linbus/tree/package-info.java
@@ -0,0 +1,22 @@
+/*
+ * Copyright (c) EngineHub
+ * Copyright (c) contributors
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+@NullMarked
+package org.enginehub.linbus.tree;
+
+import org.jspecify.annotations.NullMarked;
diff --git a/tree/src/test/java/org/enginehub/linbus/tree/truth/LinTagSubject.java b/tree/src/test/java/org/enginehub/linbus/tree/truth/LinTagSubject.java
index 6f0b8be..c217163 100644
--- a/tree/src/test/java/org/enginehub/linbus/tree/truth/LinTagSubject.java
+++ b/tree/src/test/java/org/enginehub/linbus/tree/truth/LinTagSubject.java
@@ -32,7 +32,6 @@
import com.google.common.truth.PrimitiveLongArraySubject;
import com.google.common.truth.StringSubject;
import com.google.common.truth.Subject;
-import org.checkerframework.checker.nullness.qual.Nullable;
import org.enginehub.linbus.tree.LinByteArrayTag;
import org.enginehub.linbus.tree.LinByteTag;
import org.enginehub.linbus.tree.LinCompoundTag;
@@ -48,6 +47,7 @@
import org.enginehub.linbus.tree.LinStringTag;
import org.enginehub.linbus.tree.LinTag;
import org.enginehub.linbus.tree.LinTagType;
+import org.jspecify.annotations.Nullable;
import static com.google.common.truth.Truth.assertAbout;
@@ -60,7 +60,7 @@ public static LinTagSubject assertThat(@Nullable LinTag> tag) {
return assertAbout(linTags()).that(tag);
}
- private final LinTag> tag;
+ private final @Nullable LinTag> tag;
protected LinTagSubject(FailureMetadata metadata, @Nullable LinTag> actual) {
super(metadata, actual);
@@ -69,6 +69,7 @@ protected LinTagSubject(FailureMetadata metadata, @Nullable LinTag> actual) {
public void isOfType(LinTagType> type) {
isNotNull();
+ assert tag != null : "checked by isNotNull()";
if (this.tag.type() != type) {
failWithActual(
Fact.fact("expected", type),
@@ -79,71 +80,85 @@ public void isOfType(LinTagType> type) {
public PrimitiveByteArraySubject byteArrayValue() {
isOfType(LinTagType.byteArrayTag());
+ assert tag != null : "checked by isOfType()";
return check("byteArrayValue()").that(((LinByteArrayTag) tag).value());
}
public ComparableSubject byteValue() {
isOfType(LinTagType.byteTag());
+ assert tag != null : "checked by isOfType()";
return check("byteValue()").that(((LinByteTag) tag).value());
}
public MapSubject compoundValue() {
isOfType(LinTagType.compoundTag());
+ assert tag != null : "checked by isOfType()";
return check("compoundValue()").that(((LinCompoundTag) tag).value());
}
public DoubleSubject doubleValue() {
isOfType(LinTagType.doubleTag());
+ assert tag != null : "checked by isOfType()";
return check("doubleValue()").that(((LinDoubleTag) tag).value());
}
public Subject endValue() {
isOfType(LinTagType.endTag());
+ assert tag != null : "checked by isOfType()";
return check("endValue()").that(((LinEndTag) tag).value());
}
public FloatSubject floatValue() {
isOfType(LinTagType.floatTag());
+ assert tag != null : "checked by isOfType()";
return check("floatValue()").that(((LinFloatTag) tag).value());
}
public PrimitiveIntArraySubject intArrayValue() {
isOfType(LinTagType.intArrayTag());
+ assert tag != null : "checked by isOfType()";
return check("intArrayValue()").that(((LinIntArrayTag) tag).value());
}
public IntegerSubject intValue() {
isOfType(LinTagType.intTag());
+ assert tag != null : "checked by isOfType()";
return check("intValue()").that(((LinIntTag) tag).value());
}
public IterableSubject listValue() {
isOfType(LinTagType.listTag());
+ assert tag != null : "checked by isOfType()";
return check("listValue()").that(((LinListTag>) tag).value());
}
public PrimitiveLongArraySubject longArrayValue() {
isOfType(LinTagType.longArrayTag());
+ assert tag != null : "checked by isOfType()";
return check("longArrayValue()").that(((LinLongArrayTag) tag).value());
}
public LongSubject longValue() {
isOfType(LinTagType.longTag());
+ assert tag != null : "checked by isOfType()";
return check("longValue()").that(((LinLongTag) tag).value());
}
public ComparableSubject shortValue() {
isOfType(LinTagType.shortTag());
+ assert tag != null : "checked by isOfType()";
return check("shortValue()").that(((LinShortTag) tag).value());
}
public StringSubject stringValue() {
isOfType(LinTagType.stringTag());
+ assert tag != null : "checked by isOfType()";
return check("stringValue()").that(((LinStringTag) tag).value());
}
public LinTagSubject getTagByKey(String key) {
isOfType(LinTagType.compoundTag());
+ assert tag != null : "checked by isOfType()";
return check("[%s]", key)
.about(linTags())
.that(((LinCompoundTag) tag).value().get(key));
@@ -151,6 +166,7 @@ public LinTagSubject getTagByKey(String key) {
public LinTagSubject getTagByIndex(int index) {
isOfType(LinTagType.listTag());
+ assert tag != null : "checked by isOfType()";
return check("[%s]", index)
.about(linTags())
.that(((LinListTag>) tag).value().get(index));
diff --git a/tree/src/test/java/org/enginehub/linbus/tree/truth/package-info.java b/tree/src/test/java/org/enginehub/linbus/tree/truth/package-info.java
new file mode 100644
index 0000000..c89f1a0
--- /dev/null
+++ b/tree/src/test/java/org/enginehub/linbus/tree/truth/package-info.java
@@ -0,0 +1,22 @@
+/*
+ * Copyright (c) EngineHub
+ * Copyright (c) contributors
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+@NullMarked
+package org.enginehub.linbus.tree.truth;
+
+import org.jspecify.annotations.NullMarked;