Skip to content

Commit 2f199cc

Browse files
committed
Add @NotNull and @Nullable annotations to methods and parameters across modules
- Annotate `equals`, `toString`, and other critical methods with nullability annotations for improved clarity and static analysis. - Adjust constructors and method signatures to explicitly define nullable parameters. - Update imports where necessary to support new annotations. Signed-off-by: Erik Pförtner <splatcrafter@splatgames.de>
1 parent 0318ba3 commit 2f199cc

48 files changed

Lines changed: 199 additions & 72 deletions

File tree

Some content is hidden

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

aether-datafixers-api/src/main/java/de/splatgames/aether/datafixers/api/DataVersion.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import de.splatgames.aether.datafixers.api.fix.DataFixer;
2828
import de.splatgames.aether.datafixers.api.schema.Schema;
2929
import org.jetbrains.annotations.NotNull;
30+
import org.jetbrains.annotations.Nullable;
3031

3132
import java.util.Objects;
3233

@@ -171,7 +172,7 @@ public int compareTo(@NotNull final DataVersion o) {
171172
* @see #hashCode()
172173
*/
173174
@Override
174-
public boolean equals(final Object obj) {
175+
public boolean equals(@Nullable final Object obj) {
175176
if (this == obj) {
176177
return true;
177178
}
@@ -222,6 +223,7 @@ public int hashCode() {
222223
* @return a string representation of this data version in the format {@code "DataVersion{version=N}"}
223224
*/
224225
@Override
226+
@NotNull
225227
public String toString() {
226228
return "DataVersion{" + "version=" + this.version + '}';
227229
}

aether-datafixers-api/src/main/java/de/splatgames/aether/datafixers/api/TypeReference.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import de.splatgames.aether.datafixers.api.type.Type;
2929
import de.splatgames.aether.datafixers.api.type.TypeRegistry;
3030
import org.jetbrains.annotations.NotNull;
31+
import org.jetbrains.annotations.Nullable;
3132

3233
/**
3334
* A unique identifier for a data type in the data fixing system.
@@ -183,7 +184,7 @@ public int hashCode() {
183184
* @see #hashCode()
184185
*/
185186
@Override
186-
public boolean equals(final Object obj) {
187+
public boolean equals(@Nullable final Object obj) {
187188
if (this == obj) {
188189
return true;
189190
}
@@ -217,6 +218,7 @@ public boolean equals(final Object obj) {
217218
* @see #getId()
218219
*/
219220
@Override
221+
@NotNull
220222
public String toString() {
221223
return "TypeReference{" + "id='" + this.id + '\'' + '}';
222224
}

aether-datafixers-api/src/main/java/de/splatgames/aether/datafixers/api/dynamic/TaggedDynamic.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import com.google.common.base.Preconditions;
2626
import de.splatgames.aether.datafixers.api.TypeReference;
2727
import org.jetbrains.annotations.NotNull;
28+
import org.jetbrains.annotations.Nullable;
2829

2930
/**
3031
* A {@link Dynamic} value paired with a {@link TypeReference} identifier.
@@ -200,7 +201,7 @@ public Dynamic<?> value() {
200201
* @return {@code true} if this object is the same as the obj argument; {@code false} otherwise
201202
*/
202203
@Override
203-
public boolean equals(final Object obj) {
204+
public boolean equals(@Nullable final Object obj) {
204205
if (this == obj) {
205206
return true;
206207
}
@@ -237,6 +238,7 @@ public int hashCode() {
237238
* @return a string representation of the object
238239
*/
239240
@Override
241+
@NotNull
240242
public String toString() {
241243
return "TaggedDynamic{" +
242244
"type=" + this.type +

aether-datafixers-api/src/main/java/de/splatgames/aether/datafixers/api/exception/DataFixerException.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ public String getContext() {
155155
* @return the message with context, or just the message if no context
156156
*/
157157
@Override
158+
@NotNull
158159
public String toString() {
159160
final String base = getClass().getSimpleName() + ": " + getMessage();
160161
if (this.context != null) {

aether-datafixers-api/src/main/java/de/splatgames/aether/datafixers/api/fix/Fixes.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ public Optional<Typed<?>> rewrite(@NotNull final Type<?> type,
147147
}
148148

149149
@Override
150+
@NotNull
150151
public String toString() {
151152
return name;
152153
}
@@ -210,6 +211,7 @@ public Optional<Typed<?>> rewrite(@NotNull final Type<?> inputType,
210211
}
211212

212213
@Override
214+
@NotNull
213215
public String toString() {
214216
return name;
215217
}
@@ -309,6 +311,7 @@ public static <T, A> TypeRewriteRule addField(@NotNull final DynamicOps<T> ops,
309311
}
310312

311313
@Override
314+
@NotNull
312315
public String toString() {
313316
return "addField(" + fieldName + ")";
314317
}
@@ -390,6 +393,7 @@ public static <T> TypeRewriteRule fixChoice(@NotNull final DynamicOps<T> ops,
390393
}
391394

392395
@Override
396+
@NotNull
393397
public String toString() {
394398
return "fixChoice(" + tagField + ", " + fixByTag.keySet() + ")";
395399
}
@@ -447,6 +451,7 @@ public static <T> TypeRewriteRule renameChoice(@NotNull final DynamicOps<T> ops,
447451
}
448452

449453
@Override
454+
@NotNull
450455
public String toString() {
451456
return "renameChoice(" + tagField + ": " + oldTag + " -> " + newTag + ")";
452457
}
@@ -520,6 +525,7 @@ public Optional<Typed<?>> rewrite(@NotNull final Type<?> type,
520525
}
521526

522527
@Override
528+
@NotNull
523529
public String toString() {
524530
return name;
525531
}

aether-datafixers-api/src/main/java/de/splatgames/aether/datafixers/api/result/DataResult.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,7 @@ public DataResult<A> promotePartial(@NotNull final Consumer<String> onError) {
778778
* @return {@code true} if the other object is a Success with an equal value
779779
*/
780780
@Override
781-
public boolean equals(final Object obj) {
781+
public boolean equals(@Nullable final Object obj) {
782782
if (this == obj) {
783783
return true;
784784
}
@@ -803,8 +803,8 @@ public int hashCode() {
803803
*
804804
* @return a string in the format "DataResult.Success[value]"
805805
*/
806-
@NotNull
807806
@Override
807+
@NotNull
808808
public String toString() {
809809
return "DataResult.Success[" + this.value + "]";
810810
}
@@ -1150,7 +1150,7 @@ public DataResult<A> promotePartial(@NotNull final Consumer<String> onError) {
11501150
* @return {@code true} if the other object is an Error with equal message and partial
11511151
*/
11521152
@Override
1153-
public boolean equals(final Object obj) {
1153+
public boolean equals(@Nullable final Object obj) {
11541154
if (this == obj) {
11551155
return true;
11561156
}
@@ -1177,8 +1177,8 @@ public int hashCode() {
11771177
*
11781178
* @return a string in the format "DataResult.Error[message]" or "DataResult.Error[message, partial=value]"
11791179
*/
1180-
@NotNull
11811180
@Override
1181+
@NotNull
11821182
public String toString() {
11831183
if (this.partial != null) {
11841184
return "DataResult.Error[" + this.message + ", partial=" + this.partial + "]";

0 commit comments

Comments
 (0)