Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Optional;

/**
Expand Down Expand Up @@ -766,8 +765,8 @@ public <T> DataResult<T> encode(@NotNull final Pair<F, S> input,
Preconditions.checkNotNull(input, "input must not be null");
Preconditions.checkNotNull(ops, "ops must not be null");
Preconditions.checkNotNull(prefix, "prefix must not be null");
return first.encode(Objects.requireNonNull(input.first()), ops, prefix)
.flatMap(t -> second.encode(Objects.requireNonNull(input.second()), ops, t));
return first.encode(Preconditions.checkNotNull(input.first(), "pair first must not be null"), ops, prefix)
.flatMap(t -> second.encode(Preconditions.checkNotNull(input.second(), "pair second must not be null"), ops, t));
}

@NotNull
Expand All @@ -777,13 +776,13 @@ public <T> DataResult<Pair<Pair<F, S>, T>> decode(@NotNull final DynamicOps<T> o
Preconditions.checkNotNull(ops, "ops must not be null");
Preconditions.checkNotNull(input, "input must not be null");
return first.decode(ops, input).flatMap(p1 ->
second.decode(ops, Objects.requireNonNull(p1.second())).map(p2 ->
second.decode(ops, Preconditions.checkNotNull(p1.second(), "first decode remainder must not be null")).map(p2 ->
Pair.of(
Pair.of(
Objects.requireNonNull(p1.first()),
Objects.requireNonNull(p2.first())
Preconditions.checkNotNull(p1.first(), "first decode value must not be null"),
Preconditions.checkNotNull(p2.first(), "second decode value must not be null")
),
Objects.requireNonNull(p2.second())
Preconditions.checkNotNull(p2.second(), "second decode remainder must not be null")
)
)
);
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@
* @param startTime the instant when the fix started
* @param duration the total time taken to apply the fix
* @param ruleApplications list of individual rule applications within this fix
* @param beforeSnapshot optional snapshot of data before the fix was applied
* @param afterSnapshot optional snapshot of data after the fix was applied
* @param beforeSnapshot snapshot of data before the fix was applied, or {@code null}
* if snapshot capture was disabled in {@link DiagnosticOptions}
* @param afterSnapshot snapshot of data after the fix was applied, or {@code null}
* if snapshot capture was disabled or the fix failed
* @author Erik Pförtner
* @see RuleApplication
* @see MigrationReport
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.io.Serial;

/**
* Base exception class for all data fixer related errors.
*
Expand Down Expand Up @@ -74,6 +76,15 @@
*/
public class DataFixerException extends RuntimeException {

/**
* Serial version UID for serialization compatibility.
*/
@Serial
private static final long serialVersionUID = 2074356976574888083L;

/**
* Optional context information about where the error occurred (e.g., field path, type name).
*/
@Nullable
private final String context;

Expand Down Expand Up @@ -145,9 +156,10 @@ public String getContext() {
*/
@Override
public String toString() {
final String base = getClass().getSimpleName() + ": " + getMessage();
if (this.context != null) {
return super.toString() + " [context: " + this.context + "]";
return base + " [context: " + this.context + "]";
}
return super.toString();
return base;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@

import org.jetbrains.annotations.NotNull;

import java.io.Serial;
import java.io.Serializable;

/**
* A singleton type representing the absence of a meaningful value.
*
Expand Down Expand Up @@ -65,7 +68,7 @@
* @see de.splatgames.aether.datafixers.api.result.DataResult
* @since 0.1.0
*/
public final class Unit {
public final class Unit implements Serializable {

/**
* The singleton instance of Unit.
Expand All @@ -76,6 +79,15 @@ public final class Unit {
@NotNull
public static final Unit INSTANCE = new Unit();

/**
* Serial version UID for serialization compatibility.
*
* <p>This value is arbitrary but should be changed if the class structure changes in a way that affects
* serialization.</p>
*/
@Serial
private static final long serialVersionUID = -7628105959309438762L;

/**
* Private constructor to prevent external instantiation.
*
Expand Down Expand Up @@ -120,4 +132,14 @@ public int hashCode() {
public boolean equals(final Object obj) {
return obj instanceof Unit;
}

/**
* Preserves the singleton guarantee during deserialization.
*
* @return {@link #INSTANCE}
*/
@Serial
private Object readResolve() {
return INSTANCE;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@
* A fluent builder for creating {@link Dynamic} objects.
*
* <p>This builder provides a clean, readable API for constructing test data
* without the boilerplate of manual JSON construction. It supports primitives,
* without the boilerplate of manual JSON construction. Each builder instance should
* only be used for a single {@link #build()} call — create a new instance for each
* Dynamic value. It supports primitives,
* nested objects, and lists through method chaining.</p>
*
* <h2>Basic Usage</h2>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,22 @@ public TestDataListBuilder<T> addAll(final double... values) {
return this;
}

/**
* Adds multiple float elements to the list.
*
* @param values the float values
* @return this builder for chaining
* @throws NullPointerException if {@code values} is null
*/
@NotNull
public TestDataListBuilder<T> addAll(final float... values) {
Preconditions.checkNotNull(values, "values must not be null");
for (final float value : values) {
this.add(value);
}
return this;
}

/**
* Adds multiple boolean elements to the list.
*
Expand Down
Loading