diff --git a/build-logic/src/main/kotlin/jnoise.common-conventions.gradle.kts b/build-logic/src/main/kotlin/jnoise.common-conventions.gradle.kts index d37650a..27b2576 100644 --- a/build-logic/src/main/kotlin/jnoise.common-conventions.gradle.kts +++ b/build-logic/src/main/kotlin/jnoise.common-conventions.gradle.kts @@ -15,11 +15,11 @@ repositories { } dependencies { - // Jetbrains annotations - compileOnly("org.jetbrains:annotations:23.0.0") + // JSpecify Annotations + implementation("org.jspecify:jspecify:0.3.0") // JUnit testing framework - testImplementation("org.junit.jupiter:junit-jupiter-api:5.8.2") - testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.8.2") + testImplementation("org.junit.jupiter:junit-jupiter-api:5.10.0") + testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.10.0") } tasks { diff --git a/core/src/main/java/de/articdive/jnoise/core/api/noisegen/SeededExplicitNoiseGenerator.java b/core/src/main/java/de/articdive/jnoise/core/api/noisegen/SeededExplicitNoiseGenerator.java index e36462a..afc5773 100644 --- a/core/src/main/java/de/articdive/jnoise/core/api/noisegen/SeededExplicitNoiseGenerator.java +++ b/core/src/main/java/de/articdive/jnoise/core/api/noisegen/SeededExplicitNoiseGenerator.java @@ -1,6 +1,6 @@ package de.articdive.jnoise.core.api.noisegen; -import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked; /** * Interface that denotes a {@link SeededNoiseGenerator}, which can additionally evaluate a {@link NoiseResult} at a location. @@ -8,6 +8,7 @@ * @param {@link NoiseResult} class * @author Articdive */ +@NullMarked public interface SeededExplicitNoiseGenerator extends ExplicitNoiseGenerator, SeededNoiseGenerator { /** * Evaluates noise at a 1D point. @@ -16,7 +17,6 @@ public interface SeededExplicitNoiseGenerator extends Ex * @param seed seed for the {@link SeededNoiseGenerator} to use. * @return {@link NR} denoting the noise value at the 1D point. */ - @NotNull NR evaluateNoiseResult(double x, long seed); /** @@ -27,7 +27,6 @@ public interface SeededExplicitNoiseGenerator extends Ex * @param seed seed for the {@link SeededNoiseGenerator} to use. * @return {@link NR} denoting the noise value at the 2D point. */ - @NotNull NR evaluateNoiseResult(double x, double y, long seed); /** @@ -39,7 +38,6 @@ public interface SeededExplicitNoiseGenerator extends Ex * @param seed seed for the {@link SeededNoiseGenerator} to use. * @return {@link NR} denoting the noise value at the 3D point. */ - @NotNull NR evaluateNoiseResult(double x, double y, double z, long seed); /** @@ -52,6 +50,5 @@ public interface SeededExplicitNoiseGenerator extends Ex * @param seed seed for the {@link SeededNoiseGenerator} to use. * @return {@link NR} denoting the noise value at the 4D point. */ - @NotNull NR evaluateNoiseResult(double x, double y, double z, double w, long seed); } diff --git a/core/src/main/java/de/articdive/jnoise/core/api/pipeline/ExplicitNoiseSource.java b/core/src/main/java/de/articdive/jnoise/core/api/pipeline/ExplicitNoiseSource.java index 777188e..a658b8b 100644 --- a/core/src/main/java/de/articdive/jnoise/core/api/pipeline/ExplicitNoiseSource.java +++ b/core/src/main/java/de/articdive/jnoise/core/api/pipeline/ExplicitNoiseSource.java @@ -1,7 +1,7 @@ package de.articdive.jnoise.core.api.pipeline; import de.articdive.jnoise.core.api.noisegen.NoiseResult; -import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked; /** * Interface that denotes an explicit {@link NoiseSource}, which can evaluate a {@link NoiseResult} at a location. @@ -9,6 +9,7 @@ * * @author Articdive */ +@NullMarked public interface ExplicitNoiseSource extends NoiseSource { /** * Evaluates noise at a 1D point. @@ -16,7 +17,6 @@ public interface ExplicitNoiseSource extends NoiseSource * @param x X-Coordinate of the 1D point. * @return {@link NR} denoting the noise value at the 1D point. */ - @NotNull NR evaluateNoiseResult(double x); /** @@ -26,7 +26,6 @@ public interface ExplicitNoiseSource extends NoiseSource * @param y Y-Coordinate of the 2D point. * @return {@link NR} denoting the noise value at the 2D point. */ - @NotNull NR evaluateNoiseResult(double x, double y); /** @@ -37,7 +36,6 @@ public interface ExplicitNoiseSource extends NoiseSource * @param z Z-Coordinate of the 3D point. * @return {@link NR} denoting the noise value at the 3D point. */ - @NotNull NR evaluateNoiseResult(double x, double y, double z); /** @@ -49,6 +47,5 @@ public interface ExplicitNoiseSource extends NoiseSource * @param w W-Coordinate of the 4D point. * @return {@link NR} denoting the noise value at the 4D point. */ - @NotNull NR evaluateNoiseResult(double x, double y, double z, double w); } diff --git a/core/src/main/java/de/articdive/jnoise/core/api/pipeline/NoiseSourceBuilder.java b/core/src/main/java/de/articdive/jnoise/core/api/pipeline/NoiseSourceBuilder.java index 30a28bd..72c0c52 100644 --- a/core/src/main/java/de/articdive/jnoise/core/api/pipeline/NoiseSourceBuilder.java +++ b/core/src/main/java/de/articdive/jnoise/core/api/pipeline/NoiseSourceBuilder.java @@ -1,17 +1,18 @@ package de.articdive.jnoise.core.api.pipeline; -import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked; /** * Interface that denotes a builder for a {@link NoiseSource}. * * @author Articdive */ +@NullMarked public interface NoiseSourceBuilder { /** * Builds the NoiseSource. * * @return {@link NoiseSource} resulting from the parameters of the {@link NoiseSourceBuilder}. */ - @NotNull NoiseSource build(); + NoiseSource build(); } \ No newline at end of file diff --git a/core/src/main/java/de/articdive/jnoise/core/api/transformers/DetailedTransformer.java b/core/src/main/java/de/articdive/jnoise/core/api/transformers/DetailedTransformer.java index 2cf76b3..a2ef0db 100644 --- a/core/src/main/java/de/articdive/jnoise/core/api/transformers/DetailedTransformer.java +++ b/core/src/main/java/de/articdive/jnoise/core/api/transformers/DetailedTransformer.java @@ -3,7 +3,7 @@ import de.articdive.jnoise.core.util.vectors.Vector2D; import de.articdive.jnoise.core.util.vectors.Vector3D; import de.articdive.jnoise.core.util.vectors.Vector4D; -import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked; /** * Interface that denotes a detailed transformer, which is used to transform coordinate tuples parts before the noise generation step. @@ -11,6 +11,7 @@ * * @author Articdive */ +@NullMarked public interface DetailedTransformer { /** * Transforms an x coordinate before noise evaluation. @@ -27,7 +28,7 @@ public interface DetailedTransformer { * @param y Y coordinate to transform. * @return {@link Vector2D} containing the transformed x and y coordinates. */ - @NotNull Vector2D transform(double x, double y); + Vector2D transform(double x, double y); /** * Transforms an x, y and z coordinate before noise evaluation. @@ -37,7 +38,7 @@ public interface DetailedTransformer { * @param z Z coordinate to transform. * @return {@link Vector3D} containing the transformed x, y and z coordinates. */ - @NotNull Vector3D transform(double x, double y, double z); + Vector3D transform(double x, double y, double z); /** * Transforms an x, y, z and w coordinate before noise evaluation. @@ -48,5 +49,5 @@ public interface DetailedTransformer { * @param w W coordinate to transform. * @return {@link Vector4D} containing the transformed x, y, z and w coordinates. */ - @NotNull Vector4D transform(double x, double y, double z, double w); + Vector4D transform(double x, double y, double z, double w); } diff --git a/core/src/main/java/de/articdive/jnoise/core/util/vectors/Vector1D.java b/core/src/main/java/de/articdive/jnoise/core/util/vectors/Vector1D.java index 595884c..57b3675 100644 --- a/core/src/main/java/de/articdive/jnoise/core/util/vectors/Vector1D.java +++ b/core/src/main/java/de/articdive/jnoise/core/util/vectors/Vector1D.java @@ -1,12 +1,13 @@ package de.articdive.jnoise.core.util.vectors; -import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked; /** * Record that denotes a mathematical 1D vector with an X component. * * @author Articdive */ +@NullMarked public record Vector1D(double x) implements Vector { /** @@ -15,7 +16,7 @@ public record Vector1D(double x) implements Vector { * @param vector1D {@link Vector1D} other vector to calculate the dot product with. * @return the dot product of the two vectors. */ - public double dot(@NotNull Vector1D vector1D) { + public double dot(Vector1D vector1D) { return (x * vector1D.x); } } diff --git a/core/src/main/java/de/articdive/jnoise/core/util/vectors/Vector2D.java b/core/src/main/java/de/articdive/jnoise/core/util/vectors/Vector2D.java index 816b258..97bee41 100644 --- a/core/src/main/java/de/articdive/jnoise/core/util/vectors/Vector2D.java +++ b/core/src/main/java/de/articdive/jnoise/core/util/vectors/Vector2D.java @@ -1,12 +1,13 @@ package de.articdive.jnoise.core.util.vectors; -import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked; /** * Record that denotes a mathematical 2D vector with an X and Y component. * * @author Articdive */ +@NullMarked public record Vector2D(double x, double y) implements Vector { /** @@ -15,7 +16,7 @@ public record Vector2D(double x, double y) implements Vector { * @param vector2D {@link Vector2D} other vector to calculate the dot product with. * @return the dot product of the two vectors. */ - public double dot(@NotNull Vector2D vector2D) { + public double dot(Vector2D vector2D) { return (x * vector2D.x) + (y * vector2D.y); } } \ No newline at end of file diff --git a/core/src/main/java/de/articdive/jnoise/core/util/vectors/Vector3D.java b/core/src/main/java/de/articdive/jnoise/core/util/vectors/Vector3D.java index 58cf6b1..67f85f1 100644 --- a/core/src/main/java/de/articdive/jnoise/core/util/vectors/Vector3D.java +++ b/core/src/main/java/de/articdive/jnoise/core/util/vectors/Vector3D.java @@ -1,12 +1,13 @@ package de.articdive.jnoise.core.util.vectors; -import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked; /** * Record that denotes a mathematical 3D vector with an X, Y and Z component. * * @author Articdive */ +@NullMarked public record Vector3D(double x, double y, double z) implements Vector { /** @@ -15,7 +16,7 @@ public record Vector3D(double x, double y, double z) implements Vector { * @param vector3D {@link Vector3D} other vector to calculate the dot product with. * @return the dot product of the two vectors. */ - public double dot(@NotNull Vector3D vector3D) { + public double dot(Vector3D vector3D) { return (x * vector3D.x) + (y * vector3D.y) + (z * vector3D.z); } } \ No newline at end of file diff --git a/core/src/main/java/de/articdive/jnoise/core/util/vectors/Vector4D.java b/core/src/main/java/de/articdive/jnoise/core/util/vectors/Vector4D.java index 4c4f7f4..cffa6d0 100644 --- a/core/src/main/java/de/articdive/jnoise/core/util/vectors/Vector4D.java +++ b/core/src/main/java/de/articdive/jnoise/core/util/vectors/Vector4D.java @@ -1,12 +1,13 @@ package de.articdive.jnoise.core.util.vectors; -import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked; /** * Record that denotes a mathematical 4D vector with an X, Y, Z and W component. * * @author Articdive */ +@NullMarked public record Vector4D(double x, double y, double z, double w) implements Vector { /** @@ -15,7 +16,7 @@ public record Vector4D(double x, double y, double z, double w) implements Vector * @param vector4D {@link Vector4D} other vector to calculate the dot product with. * @return the dot product of the two vectors. */ - public double dot(@NotNull Vector4D vector4D) { + public double dot(Vector4D vector4D) { return (x * vector4D.x) + (y * vector4D.y) + (z * vector4D.z) + (w * vector4D.w); } } \ No newline at end of file diff --git a/generators/src/main/java/de/articdive/jnoise/generators/noisegen/constant/ConstantNoiseGenerator.java b/generators/src/main/java/de/articdive/jnoise/generators/noisegen/constant/ConstantNoiseGenerator.java index cbd32ca..517fb3c 100644 --- a/generators/src/main/java/de/articdive/jnoise/generators/noisegen/constant/ConstantNoiseGenerator.java +++ b/generators/src/main/java/de/articdive/jnoise/generators/noisegen/constant/ConstantNoiseGenerator.java @@ -2,13 +2,14 @@ import de.articdive.jnoise.core.api.noisegen.NoiseGenerator; import de.articdive.jnoise.core.api.pipeline.NoiseSourceBuilder; -import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked; /** * A noise generator that always returns the constant specified. * * @author Articdive */ +@NullMarked public final class ConstantNoiseGenerator implements NoiseGenerator { private final double constant; @@ -41,7 +42,6 @@ public double evaluateNoise(double x, double y, double z, double w) { * * @return {@link ConstantNoiseBuilder}. */ - @NotNull public static ConstantNoiseBuilder newBuilder() { return new ConstantNoiseBuilder(); } @@ -49,6 +49,7 @@ public static ConstantNoiseBuilder newBuilder() { /** * Builder for the {@link ConstantNoiseGenerator}. */ + @NullMarked public static final class ConstantNoiseBuilder implements NoiseSourceBuilder { private double constant = 0; @@ -62,14 +63,12 @@ private ConstantNoiseBuilder() { * @param constant the new result for the {@link ConstantNoiseGenerator}. * @return {@link ConstantNoiseBuilder} this */ - @NotNull public ConstantNoiseBuilder setConstant(double constant) { this.constant = constant; return this; } @Override - @NotNull public ConstantNoiseGenerator build() { return new ConstantNoiseGenerator(constant); } diff --git a/generators/src/main/java/de/articdive/jnoise/generators/noisegen/opensimplex/FastSimplexNoiseGenerator.java b/generators/src/main/java/de/articdive/jnoise/generators/noisegen/opensimplex/FastSimplexNoiseGenerator.java index 9133b87..214954c 100644 --- a/generators/src/main/java/de/articdive/jnoise/generators/noisegen/opensimplex/FastSimplexNoiseGenerator.java +++ b/generators/src/main/java/de/articdive/jnoise/generators/noisegen/opensimplex/FastSimplexNoiseGenerator.java @@ -5,7 +5,7 @@ import de.articdive.jnoise.generators.noise_parameters.simplex_variants.Simplex2DVariant; import de.articdive.jnoise.generators.noise_parameters.simplex_variants.Simplex3DVariant; import de.articdive.jnoise.generators.noise_parameters.simplex_variants.Simplex4DVariant; -import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked; /** * Uses KdotJPG's the fast variant of OpenSimplex2 Noise located at https://github.com/KdotJPG/OpenSimplex2. @@ -13,6 +13,7 @@ * * @author Articdive */ +@NullMarked public final class FastSimplexNoiseGenerator implements SeededNoiseGenerator { private final long seed; private final Simplex2DVariant variant2D; @@ -21,9 +22,9 @@ public final class FastSimplexNoiseGenerator implements SeededNoiseGenerator { private FastSimplexNoiseGenerator( long seed, - @NotNull Simplex2DVariant variant2D, - @NotNull Simplex3DVariant variant3D, - @NotNull Simplex4DVariant variant4D + Simplex2DVariant variant2D, + Simplex3DVariant variant3D, + Simplex4DVariant variant4D ) { this.seed = seed; this.variant2D = variant2D; @@ -95,7 +96,6 @@ public long getSeed() { * * @return {@link FastSimplexNoiseBuilder}. */ - @NotNull public static FastSimplexNoiseBuilder newBuilder() { return new FastSimplexNoiseBuilder(); } @@ -103,6 +103,7 @@ public static FastSimplexNoiseBuilder newBuilder() { /** * Builder for the {@link FastSimplexNoiseGenerator}. */ + @NullMarked public static final class FastSimplexNoiseBuilder implements NoiseSourceBuilder { private long seed = 1729; private Simplex2DVariant variant2D = Simplex2DVariant.CLASSIC; @@ -119,7 +120,6 @@ private FastSimplexNoiseBuilder() { * @param seed the new seed for the {@link FastSimplexNoiseGenerator}. * @return {@link FastSimplexNoiseBuilder} this */ - @NotNull public FastSimplexNoiseBuilder setSeed(long seed) { this.seed = seed; return this; @@ -131,11 +131,7 @@ public FastSimplexNoiseBuilder setSeed(long seed) { * @param variant2D the new {@link Simplex2DVariant} for the {@link FastSimplexNoiseGenerator}. * @return {@link FastSimplexNoiseBuilder} this */ - @NotNull public FastSimplexNoiseBuilder setVariant2D(Simplex2DVariant variant2D) { - if (variant2D == null) { - throw new IllegalArgumentException("Simplex 2D Variant cannot be null."); - } this.variant2D = variant2D; return this; } @@ -146,11 +142,7 @@ public FastSimplexNoiseBuilder setVariant2D(Simplex2DVariant variant2D) { * @param variant3D the new {@link Simplex3DVariant} for the {@link FastSimplexNoiseGenerator}. * @return {@link FastSimplexNoiseBuilder} this */ - @NotNull public FastSimplexNoiseBuilder setVariant3D(Simplex3DVariant variant3D) { - if (variant3D == null) { - throw new IllegalArgumentException("Simplex 3D Variant cannot be null."); - } this.variant3D = variant3D; return this; } @@ -161,17 +153,12 @@ public FastSimplexNoiseBuilder setVariant3D(Simplex3DVariant variant3D) { * @param variant4D the new {@link Simplex4DVariant} for the {@link FastSimplexNoiseGenerator}. * @return {@link FastSimplexNoiseBuilder} this */ - @NotNull public FastSimplexNoiseBuilder setVariant4D(Simplex4DVariant variant4D) { - if (variant4D == null) { - throw new IllegalArgumentException("Simplex 4D Variant cannot be null."); - } this.variant4D = variant4D; return this; } @Override - @NotNull public FastSimplexNoiseGenerator build() { return new FastSimplexNoiseGenerator(seed, variant2D, variant3D, variant4D); } diff --git a/generators/src/main/java/de/articdive/jnoise/generators/noisegen/opensimplex/SuperSimplexNoiseGenerator.java b/generators/src/main/java/de/articdive/jnoise/generators/noisegen/opensimplex/SuperSimplexNoiseGenerator.java index b17c3a4..4123be4 100644 --- a/generators/src/main/java/de/articdive/jnoise/generators/noisegen/opensimplex/SuperSimplexNoiseGenerator.java +++ b/generators/src/main/java/de/articdive/jnoise/generators/noisegen/opensimplex/SuperSimplexNoiseGenerator.java @@ -5,7 +5,7 @@ import de.articdive.jnoise.generators.noise_parameters.simplex_variants.Simplex2DVariant; import de.articdive.jnoise.generators.noise_parameters.simplex_variants.Simplex3DVariant; import de.articdive.jnoise.generators.noise_parameters.simplex_variants.Simplex4DVariant; -import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked; /** * Uses KdotJPG's the super variant of OpenSimplex2 Noise located at https://github.com/KdotJPG/OpenSimplex2. @@ -13,6 +13,7 @@ * * @author Articdive */ +@NullMarked public final class SuperSimplexNoiseGenerator implements SeededNoiseGenerator { private final long seed; private final Simplex2DVariant variant2D; @@ -21,9 +22,9 @@ public final class SuperSimplexNoiseGenerator implements SeededNoiseGenerator { private SuperSimplexNoiseGenerator( long seed, - @NotNull Simplex2DVariant variant2D, - @NotNull Simplex3DVariant variant3D, - @NotNull Simplex4DVariant variant4D + Simplex2DVariant variant2D, + Simplex3DVariant variant3D, + Simplex4DVariant variant4D ) { this.seed = seed; this.variant2D = variant2D; @@ -95,7 +96,6 @@ public long getSeed() { * * @return {@link SuperSimplexNoiseBuilder}. */ - @NotNull public static SuperSimplexNoiseBuilder newBuilder() { return new SuperSimplexNoiseBuilder(); } @@ -103,6 +103,7 @@ public static SuperSimplexNoiseBuilder newBuilder() { /** * Builder for the {@link SuperSimplexNoiseGenerator}. */ + @NullMarked public static final class SuperSimplexNoiseBuilder implements NoiseSourceBuilder { private long seed = 1729; private Simplex2DVariant variant2D = Simplex2DVariant.CLASSIC; @@ -119,7 +120,6 @@ private SuperSimplexNoiseBuilder() { * @param seed the new seed for the {@link SuperSimplexNoiseGenerator}. * @return {@link SuperSimplexNoiseBuilder} this */ - @NotNull public SuperSimplexNoiseBuilder setSeed(long seed) { this.seed = seed; return this; @@ -131,11 +131,7 @@ public SuperSimplexNoiseBuilder setSeed(long seed) { * @param variant2D the new {@link Simplex2DVariant} for the {@link SuperSimplexNoiseGenerator}. * @return {@link SuperSimplexNoiseBuilder} this */ - @NotNull public SuperSimplexNoiseBuilder setVariant2D(Simplex2DVariant variant2D) { - if (variant2D == null) { - throw new IllegalArgumentException("Simplex 2D Variant cannot be null."); - } this.variant2D = variant2D; return this; } @@ -146,11 +142,7 @@ public SuperSimplexNoiseBuilder setVariant2D(Simplex2DVariant variant2D) { * @param variant3D the new {@link Simplex3DVariant} for the {@link SuperSimplexNoiseGenerator}. * @return {@link SuperSimplexNoiseBuilder} this */ - @NotNull public SuperSimplexNoiseBuilder setVariant3D(Simplex3DVariant variant3D) { - if (variant3D == null) { - throw new IllegalArgumentException("Simplex 3D Variant cannot be null."); - } this.variant3D = variant3D; return this; } @@ -161,17 +153,12 @@ public SuperSimplexNoiseBuilder setVariant3D(Simplex3DVariant variant3D) { * @param variant4D the new {@link Simplex4DVariant} for the {@link SuperSimplexNoiseGenerator}. * @return {@link SuperSimplexNoiseBuilder} this */ - @NotNull public SuperSimplexNoiseBuilder setVariant4D(Simplex4DVariant variant4D) { - if (variant4D == null) { - throw new IllegalArgumentException("Simplex 4D Variant cannot be null."); - } this.variant4D = variant4D; return this; } @Override - @NotNull public SuperSimplexNoiseGenerator build() { return new SuperSimplexNoiseGenerator(seed, variant2D, variant3D, variant4D); } diff --git a/generators/src/main/java/de/articdive/jnoise/generators/noisegen/pattern/CheckerboardNoiseGenerator.java b/generators/src/main/java/de/articdive/jnoise/generators/noisegen/pattern/CheckerboardNoiseGenerator.java index c898e4e..18885e4 100644 --- a/generators/src/main/java/de/articdive/jnoise/generators/noisegen/pattern/CheckerboardNoiseGenerator.java +++ b/generators/src/main/java/de/articdive/jnoise/generators/noisegen/pattern/CheckerboardNoiseGenerator.java @@ -2,7 +2,7 @@ import de.articdive.jnoise.core.api.noisegen.NoiseGenerator; import de.articdive.jnoise.core.api.pipeline.NoiseSourceBuilder; -import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked; /** * A noise generator that returns a checkerboard of unit-sized blocks alternating between 0.0 and 1.0. @@ -10,6 +10,7 @@ * * @author Articdive */ +@NullMarked public final class CheckerboardNoiseGenerator implements NoiseGenerator { private CheckerboardNoiseGenerator() { @@ -50,7 +51,6 @@ public double evaluateNoise(double x, double y, double z, double w) { * * @return {@link CheckerboardNoiseBuilder}. */ - @NotNull public static CheckerboardNoiseBuilder newBuilder() { return new CheckerboardNoiseBuilder(); } @@ -58,6 +58,7 @@ public static CheckerboardNoiseBuilder newBuilder() { /** * Builder for the {@link CheckerboardNoiseGenerator}. */ + @NullMarked public static final class CheckerboardNoiseBuilder implements NoiseSourceBuilder { private CheckerboardNoiseBuilder() { @@ -65,7 +66,6 @@ private CheckerboardNoiseBuilder() { } @Override - @NotNull public CheckerboardNoiseGenerator build() { return new CheckerboardNoiseGenerator(); } diff --git a/generators/src/main/java/de/articdive/jnoise/generators/noisegen/pattern/CylinderNoiseGenerator.java b/generators/src/main/java/de/articdive/jnoise/generators/noisegen/pattern/CylinderNoiseGenerator.java index f09aac0..2de5ddc 100644 --- a/generators/src/main/java/de/articdive/jnoise/generators/noisegen/pattern/CylinderNoiseGenerator.java +++ b/generators/src/main/java/de/articdive/jnoise/generators/noisegen/pattern/CylinderNoiseGenerator.java @@ -2,7 +2,7 @@ import de.articdive.jnoise.core.api.noisegen.NoiseGenerator; import de.articdive.jnoise.core.api.pipeline.NoiseSourceBuilder; -import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked; /** * A noise generator that returns a concentric cylinders (centered on the origin) extending infinitely. @@ -13,6 +13,7 @@ * * @author Articdive */ +@NullMarked public final class CylinderNoiseGenerator implements NoiseGenerator { private CylinderNoiseGenerator() { @@ -58,7 +59,6 @@ public double evaluateNoise(double x, double y, double z, double w) { * * @return {@link CylinderNoiseBuilder}. */ - @NotNull public static CylinderNoiseBuilder newBuilder() { return new CylinderNoiseBuilder(); } @@ -66,6 +66,7 @@ public static CylinderNoiseBuilder newBuilder() { /** * Builder for the {@link CylinderNoiseGenerator}. */ + @NullMarked public static final class CylinderNoiseBuilder implements NoiseSourceBuilder { private CylinderNoiseBuilder() { @@ -73,7 +74,6 @@ private CylinderNoiseBuilder() { } @Override - @NotNull public CylinderNoiseGenerator build() { return new CylinderNoiseGenerator(); } diff --git a/generators/src/main/java/de/articdive/jnoise/generators/noisegen/pattern/SphereNoiseGenerator.java b/generators/src/main/java/de/articdive/jnoise/generators/noisegen/pattern/SphereNoiseGenerator.java index f66100e..05e59a6 100644 --- a/generators/src/main/java/de/articdive/jnoise/generators/noisegen/pattern/SphereNoiseGenerator.java +++ b/generators/src/main/java/de/articdive/jnoise/generators/noisegen/pattern/SphereNoiseGenerator.java @@ -2,7 +2,7 @@ import de.articdive.jnoise.core.api.noisegen.NoiseGenerator; import de.articdive.jnoise.core.api.pipeline.NoiseSourceBuilder; -import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked; /** * A noise generator that returns a concentric spheres (centered on the origin) extending infinitely. @@ -10,6 +10,7 @@ * * @author Articdive */ +@NullMarked public final class SphereNoiseGenerator implements NoiseGenerator { private SphereNoiseGenerator() { @@ -60,7 +61,6 @@ public double evaluateNoise(double x, double y, double z, double w) { * * @return {@link SphereNoiseBuilder}. */ - @NotNull public static SphereNoiseBuilder newBuilder() { return new SphereNoiseBuilder(); } @@ -68,6 +68,7 @@ public static SphereNoiseBuilder newBuilder() { /** * Builder for the {@link SphereNoiseGenerator}. */ + @NullMarked public static final class SphereNoiseBuilder implements NoiseSourceBuilder { private SphereNoiseBuilder() { @@ -75,7 +76,6 @@ private SphereNoiseBuilder() { } @Override - @NotNull public SphereNoiseGenerator build() { return new SphereNoiseGenerator(); } diff --git a/generators/src/main/java/de/articdive/jnoise/generators/noisegen/perlin/PerlinNoiseGenerator.java b/generators/src/main/java/de/articdive/jnoise/generators/noisegen/perlin/PerlinNoiseGenerator.java index 25f421b..23b07a2 100644 --- a/generators/src/main/java/de/articdive/jnoise/generators/noisegen/perlin/PerlinNoiseGenerator.java +++ b/generators/src/main/java/de/articdive/jnoise/generators/noisegen/perlin/PerlinNoiseGenerator.java @@ -9,7 +9,7 @@ import de.articdive.jnoise.core.util.vectors.Vector3D; import de.articdive.jnoise.core.util.vectors.Vector4D; import de.articdive.jnoise.generators.noise_parameters.fade_functions.FadeFunction; -import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked; /** * Based on Ken Perlin's implementation of Perlin Noise. @@ -17,6 +17,7 @@ * * @author Articdive */ +@NullMarked public final class PerlinNoiseGenerator implements SeededNoiseGenerator { private static final Vector1D[] VECTOR_1D = new Vector1D[]{ new Vector1D(1), new Vector1D(-1) @@ -68,7 +69,7 @@ public final class PerlinNoiseGenerator implements SeededNoiseGenerator { private final Interpolation interpolation; private final FadeFunction fadeFunction; - private PerlinNoiseGenerator(long seed, @NotNull Interpolation interpolation, @NotNull FadeFunction fadeFunction) { + private PerlinNoiseGenerator(long seed, Interpolation interpolation, FadeFunction fadeFunction) { this.seed = seed; this.interpolation = interpolation; this.fadeFunction = fadeFunction; @@ -244,7 +245,6 @@ public long getSeed() { * * @return {@link PerlinNoiseBuilder}. */ - @NotNull public static PerlinNoiseBuilder newBuilder() { return new PerlinNoiseBuilder(); } @@ -252,6 +252,7 @@ public static PerlinNoiseBuilder newBuilder() { /** * Builder for the {@link PerlinNoiseGenerator}. */ + @NullMarked public static final class PerlinNoiseBuilder implements NoiseSourceBuilder { private long seed = 1729; private de.articdive.jnoise.core.api.functions.Interpolation interpolation = de.articdive.jnoise.core.api.functions.Interpolation.LINEAR; @@ -267,7 +268,6 @@ private PerlinNoiseBuilder() { * @param seed the new seed for the {@link PerlinNoiseGenerator}. * @return {@link PerlinNoiseBuilder} this */ - @NotNull public PerlinNoiseBuilder setSeed(long seed) { this.seed = seed; return this; @@ -279,11 +279,7 @@ public PerlinNoiseBuilder setSeed(long seed) { * @param interpolation The new {@link Interpolation} for the {@link PerlinNoiseGenerator}. * @return {@link PerlinNoiseBuilder} this */ - @NotNull public PerlinNoiseBuilder setInterpolation(Interpolation interpolation) { - if (interpolation == null) { - throw new IllegalArgumentException("Interpolation cannot be null."); - } this.interpolation = interpolation; return this; } @@ -294,17 +290,12 @@ public PerlinNoiseBuilder setInterpolation(Interpolation interpolation) { * @param fadeFunction the new {@link FadeFunction} for the {@link PerlinNoiseGenerator}. * @return {@link PerlinNoiseBuilder} this */ - @NotNull public PerlinNoiseBuilder setFadeFunction(FadeFunction fadeFunction) { - if (fadeFunction == null) { - throw new IllegalArgumentException("Fade function cannot be null."); - } this.fadeFunction = fadeFunction; return this; } @Override - @NotNull public PerlinNoiseGenerator build() { return new PerlinNoiseGenerator(seed, interpolation, fadeFunction); } diff --git a/generators/src/main/java/de/articdive/jnoise/generators/noisegen/random/gaussian/GaussianWhiteNoiseGenerator.java b/generators/src/main/java/de/articdive/jnoise/generators/noisegen/random/gaussian/GaussianWhiteNoiseGenerator.java index 1aa405d..6b17a97 100644 --- a/generators/src/main/java/de/articdive/jnoise/generators/noisegen/random/gaussian/GaussianWhiteNoiseGenerator.java +++ b/generators/src/main/java/de/articdive/jnoise/generators/noisegen/random/gaussian/GaussianWhiteNoiseGenerator.java @@ -3,7 +3,7 @@ import de.articdive.jnoise.core.api.noisegen.SeededNoiseGenerator; import de.articdive.jnoise.core.api.pipeline.NoiseSourceBuilder; import de.articdive.jnoise.core.util.HashUtil; -import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked; import java.util.Random; @@ -13,6 +13,7 @@ * * @author Articdive */ +@NullMarked public final class GaussianWhiteNoiseGenerator implements SeededNoiseGenerator { private final long seed; private final double mean; @@ -95,7 +96,6 @@ public long getSeed() { * * @return {@link GaussianWhiteNoiseBuilder}. */ - @NotNull public static GaussianWhiteNoiseBuilder newBuilder() { return new GaussianWhiteNoiseBuilder(); } @@ -103,6 +103,7 @@ public static GaussianWhiteNoiseBuilder newBuilder() { /** * Builder for the {@link GaussianWhiteNoiseGenerator}. */ + @NullMarked public static final class GaussianWhiteNoiseBuilder implements NoiseSourceBuilder { private long seed = 1729; @@ -120,7 +121,6 @@ private GaussianWhiteNoiseBuilder() { * @param seed the new seed for the {@link GaussianWhiteNoiseGenerator}. * @return {@link GaussianWhiteNoiseBuilder} this */ - @NotNull public GaussianWhiteNoiseGenerator.GaussianWhiteNoiseBuilder setSeed(long seed) { this.seed = seed; return this; @@ -149,7 +149,6 @@ public GaussianWhiteNoiseBuilder setStandardDeviation(double stddev) { } @Override - @NotNull public GaussianWhiteNoiseGenerator build() { return new GaussianWhiteNoiseGenerator(seed, mean, stddev); } diff --git a/generators/src/main/java/de/articdive/jnoise/generators/noisegen/random/white/WhiteNoiseGenerator.java b/generators/src/main/java/de/articdive/jnoise/generators/noisegen/random/white/WhiteNoiseGenerator.java index 34e9cc8..ce961b3 100644 --- a/generators/src/main/java/de/articdive/jnoise/generators/noisegen/random/white/WhiteNoiseGenerator.java +++ b/generators/src/main/java/de/articdive/jnoise/generators/noisegen/random/white/WhiteNoiseGenerator.java @@ -2,7 +2,7 @@ import de.articdive.jnoise.core.api.noisegen.SeededNoiseGenerator; import de.articdive.jnoise.core.api.pipeline.NoiseSourceBuilder; -import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked; import static de.articdive.jnoise.core.util.HashUtil.W_PRIME; import static de.articdive.jnoise.core.util.HashUtil.X_PRIME; @@ -14,6 +14,7 @@ * * @author Articdive */ +@NullMarked public final class WhiteNoiseGenerator implements SeededNoiseGenerator { private final long seed; @@ -100,7 +101,6 @@ private static double evaluateCoord4D(long x, long y, long z, long w, long seed) * * @return {@link WhiteNoiseBuilder}. */ - @NotNull public static WhiteNoiseBuilder newBuilder() { return new WhiteNoiseBuilder(); } @@ -108,6 +108,7 @@ public static WhiteNoiseBuilder newBuilder() { /** * Builder for the {@link WhiteNoiseGenerator}. */ + @NullMarked public static final class WhiteNoiseBuilder implements NoiseSourceBuilder { private long seed = 1729; @@ -121,14 +122,12 @@ private WhiteNoiseBuilder() { * @param seed the new seed for the {@link WhiteNoiseGenerator}. * @return {@link WhiteNoiseBuilder} this */ - @NotNull public WhiteNoiseBuilder setSeed(long seed) { this.seed = seed; return this; } @Override - @NotNull public WhiteNoiseGenerator build() { return new WhiteNoiseGenerator(seed); } diff --git a/generators/src/main/java/de/articdive/jnoise/generators/noisegen/value/ValueNoiseGenerator.java b/generators/src/main/java/de/articdive/jnoise/generators/noisegen/value/ValueNoiseGenerator.java index 9c57cdc..3c20ab4 100644 --- a/generators/src/main/java/de/articdive/jnoise/generators/noisegen/value/ValueNoiseGenerator.java +++ b/generators/src/main/java/de/articdive/jnoise/generators/noisegen/value/ValueNoiseGenerator.java @@ -4,7 +4,7 @@ import de.articdive.jnoise.core.api.noisegen.SeededNoiseGenerator; import de.articdive.jnoise.core.api.pipeline.NoiseSourceBuilder; import de.articdive.jnoise.generators.noise_parameters.fade_functions.FadeFunction; -import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked; import static de.articdive.jnoise.core.util.HashUtil.W_PRIME; import static de.articdive.jnoise.core.util.HashUtil.X_PRIME; @@ -16,12 +16,13 @@ * * @author Articdive */ +@NullMarked public final class ValueNoiseGenerator implements SeededNoiseGenerator { private final long seed; private final Interpolation interpolation; private final FadeFunction fadeFunction; - private ValueNoiseGenerator(long seed, Interpolation interpolation, @NotNull FadeFunction fadeFunction) { + private ValueNoiseGenerator(long seed, Interpolation interpolation, FadeFunction fadeFunction) { this.seed = seed; this.interpolation = interpolation; this.fadeFunction = fadeFunction; @@ -176,7 +177,6 @@ private static double evaluateCoord4D(long x, long y, long z, long w, long seed) * * @return {@link ValueNoiseBuilder}. */ - @NotNull public static ValueNoiseBuilder newBuilder() { return new ValueNoiseBuilder(); } @@ -184,6 +184,7 @@ public static ValueNoiseBuilder newBuilder() { /** * Builder for the {@link ValueNoiseGenerator}. */ + @NullMarked public static final class ValueNoiseBuilder implements NoiseSourceBuilder { private long seed = 1729; private Interpolation interpolation = Interpolation.LINEAR; @@ -199,7 +200,6 @@ private ValueNoiseBuilder() { * @param seed the new seed for the {@link ValueNoiseGenerator}. * @return {@link ValueNoiseBuilder} this */ - @NotNull public ValueNoiseBuilder setSeed(long seed) { this.seed = seed; return this; @@ -211,11 +211,7 @@ public ValueNoiseBuilder setSeed(long seed) { * @param interpolation The new {@link Interpolation} for the {@link ValueNoiseGenerator}. * @return {@link ValueNoiseBuilder} this */ - @NotNull public ValueNoiseBuilder setInterpolation(Interpolation interpolation) { - if (interpolation == null) { - throw new IllegalArgumentException("Interpolation cannot be null."); - } this.interpolation = interpolation; return this; } @@ -226,17 +222,12 @@ public ValueNoiseBuilder setInterpolation(Interpolation interpolation) { * @param fadeFunction the new {@link FadeFunction} for the {@link ValueNoiseGenerator}. * @return {@link ValueNoiseBuilder} this */ - @NotNull public ValueNoiseBuilder setFadeFunction(FadeFunction fadeFunction) { - if (fadeFunction == null) { - throw new IllegalArgumentException("Fade function cannot be null."); - } this.fadeFunction = fadeFunction; return this; } @Override - @NotNull public ValueNoiseGenerator build() { return new ValueNoiseGenerator(seed, interpolation, fadeFunction); } diff --git a/generators/src/main/java/de/articdive/jnoise/generators/noisegen/worley/WorleyNoiseGenerator.java b/generators/src/main/java/de/articdive/jnoise/generators/noisegen/worley/WorleyNoiseGenerator.java index 364d1ce..1d7915f 100644 --- a/generators/src/main/java/de/articdive/jnoise/generators/noisegen/worley/WorleyNoiseGenerator.java +++ b/generators/src/main/java/de/articdive/jnoise/generators/noisegen/worley/WorleyNoiseGenerator.java @@ -13,7 +13,7 @@ import de.articdive.jnoise.generators.noise_parameters.distance_functions.DistanceFunctionType; import de.articdive.jnoise.generators.noise_parameters.return_type_functions.ReturnDistanceFunction; import de.articdive.jnoise.generators.noise_parameters.return_type_functions.ReturnDistanceFunctionType; -import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked; import java.util.Arrays; import java.util.Random; @@ -27,6 +27,7 @@ * * @author Articdive */ +@NullMarked public final class WorleyNoiseGenerator implements SeededExplicitNoiseGenerator> { private final long seed; @@ -86,7 +87,6 @@ public double evaluateNoise(double x, double y, double z, double w) { } @Override - @NotNull public WorleyNoiseResult evaluateNoiseResult(double x, long seed) { long iX = (long) Math.floor(x); double[] distancesStack = new double[depth]; @@ -125,7 +125,6 @@ public WorleyNoiseResult evaluateNoiseResult(double x, long seed) { @Override - @NotNull public WorleyNoiseResult evaluateNoiseResult(double x, double y, long seed) { long iX = (long) Math.floor(x); long iY = (long) Math.floor(y); @@ -170,7 +169,6 @@ public WorleyNoiseResult evaluateNoiseResult(double x, double y, long se } @Override - @NotNull public WorleyNoiseResult evaluateNoiseResult(double x, double y, double z, long seed) { long iX = (long) Math.floor(x); long iY = (long) Math.floor(y); @@ -223,7 +221,6 @@ public WorleyNoiseResult evaluateNoiseResult(double x, double y, double } @Override - @NotNull public WorleyNoiseResult evaluateNoiseResult(double x, double y, double z, double w, long seed) { long iX = (long) Math.floor(x); long iY = (long) Math.floor(y); @@ -284,25 +281,21 @@ public WorleyNoiseResult evaluateNoiseResult(double x, double y, double } @Override - @NotNull public WorleyNoiseResult evaluateNoiseResult(double x) { return evaluateNoiseResult(x, seed); } @Override - @NotNull public WorleyNoiseResult evaluateNoiseResult(double x, double y) { return evaluateNoiseResult(x, y, seed); } @Override - @NotNull public WorleyNoiseResult evaluateNoiseResult(double x, double y, double z) { return evaluateNoiseResult(x, y, z, seed); } @Override - @NotNull public WorleyNoiseResult evaluateNoiseResult(double x, double y, double z, double w) { return evaluateNoiseResult(x, y, z, w, seed); } @@ -317,7 +310,6 @@ public long getSeed() { * * @return {@link WorleyNoiseBuilder}. */ - @NotNull public static WorleyNoiseBuilder newBuilder() { return new WorleyNoiseBuilder(); } @@ -325,6 +317,7 @@ public static WorleyNoiseBuilder newBuilder() { /** * Builder for the {@link WorleyNoiseGenerator}. */ + @NullMarked public static final class WorleyNoiseBuilder implements NoiseSourceBuilder { private long seed = 1729; private int depth = 1; @@ -343,7 +336,6 @@ private WorleyNoiseBuilder() { * @param seed the new seed for the {@link WorleyNoiseGenerator}. * @return {@link WorleyNoiseBuilder} this */ - @NotNull public WorleyNoiseBuilder setSeed(long seed) { this.seed = seed; return this; @@ -358,7 +350,6 @@ public WorleyNoiseBuilder setSeed(long seed) { * @param depth The new depth for the {@link WorleyNoiseGenerator}. * @return {@link WorleyNoiseBuilder} this */ - @NotNull public WorleyNoiseBuilder setDepth(int depth) { this.depth = depth; return this; @@ -370,11 +361,7 @@ public WorleyNoiseBuilder setDepth(int depth) { * @param distanceFunction The new {@link DistanceFunction} for the {@link WorleyNoiseGenerator}. * @return {@link WorleyNoiseBuilder} this */ - @NotNull public WorleyNoiseBuilder setDistanceFunction(DistanceFunction distanceFunction) { - if (distanceFunction == null) { - throw new IllegalArgumentException("Distance function cannot be null."); - } this.distanceFunction = distanceFunction; return this; } @@ -388,11 +375,7 @@ public WorleyNoiseBuilder setDistanceFunction(DistanceFunction distanceFunction) * @param fpAmountFunction The new (feature point amount function) for the {@link WorleyNoiseGenerator} * @return {@link WorleyNoiseBuilder} this */ - @NotNull public WorleyNoiseBuilder setFeaturePointAmountFunction(IntToLongFunction fpAmountFunction) { - if (fpAmountFunction == null) { - throw new IllegalArgumentException("Featurepoint amount function cannot be null."); - } this.fpAmountFunction = fpAmountFunction; return this; } @@ -407,11 +390,7 @@ public WorleyNoiseBuilder setFeaturePointAmountFunction(IntToLongFunction fpAmou * @param returnDistanceFunction The new return distance function for the {@link WorleyNoiseGenerator}. * @return {@link WorleyNoiseBuilder} this */ - @NotNull public WorleyNoiseBuilder setReturnDistanceFunction(ReturnDistanceFunction returnDistanceFunction) { - if (returnDistanceFunction == null) { - throw new IllegalArgumentException("Return distance function cannot be null."); - } this.returnDistanceFunction = returnDistanceFunction; return this; } @@ -424,15 +403,11 @@ public WorleyNoiseBuilder setReturnDistanceFunction(ReturnDistanceFunction retur * @return {@link WorleyNoiseBuilder} this */ public WorleyNoiseBuilder setMinFunction(Combiner minFunction) { - if (minFunction == null) { - throw new IllegalArgumentException("Minimization function cannot be null."); - } this.minFunction = minFunction; return this; } @Override - @NotNull public WorleyNoiseGenerator build() { if (!returnDistanceFunction.isValidArrayLength(depth)) { throw new IllegalArgumentException("Invalid depth for the specified return distance function!"); diff --git a/generators/src/main/java/de/articdive/jnoise/generators/noisegen/worley/WorleyNoiseResult.java b/generators/src/main/java/de/articdive/jnoise/generators/noisegen/worley/WorleyNoiseResult.java index 09dcb7c..451e6b2 100644 --- a/generators/src/main/java/de/articdive/jnoise/generators/noisegen/worley/WorleyNoiseResult.java +++ b/generators/src/main/java/de/articdive/jnoise/generators/noisegen/worley/WorleyNoiseResult.java @@ -3,7 +3,7 @@ import de.articdive.jnoise.core.api.modifiers.NoiseModifier; import de.articdive.jnoise.core.api.noisegen.NoiseResult; import de.articdive.jnoise.core.util.vectors.Vector; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.Nullable; /** * This class wraps the result of Worley Noise. diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index ccebba7..7f93135 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index bdc9a83..3fa8f86 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 79a61d4..1aa94a4 100755 --- a/gradlew +++ b/gradlew @@ -83,10 +83,8 @@ done # This is normally unused # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -133,10 +131,13 @@ location of your Java installation." fi else JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. @@ -144,7 +145,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC2039,SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac @@ -152,7 +153,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then '' | soft) :;; #( *) # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC2039,SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -197,11 +198,15 @@ if "$cygwin" || "$msys" ; then done fi -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ diff --git a/modules/src/main/java/de/articdive/jnoise/modules/blend/BlendModule.java b/modules/src/main/java/de/articdive/jnoise/modules/blend/BlendModule.java index 53db61c..ad0637e 100644 --- a/modules/src/main/java/de/articdive/jnoise/modules/blend/BlendModule.java +++ b/modules/src/main/java/de/articdive/jnoise/modules/blend/BlendModule.java @@ -4,8 +4,9 @@ import de.articdive.jnoise.core.api.modules.NoiseModule; import de.articdive.jnoise.core.api.pipeline.NoiseSource; import de.articdive.jnoise.core.api.pipeline.NoiseSourceBuilder; -import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked; +@NullMarked public final class BlendModule implements NoiseModule { private final NoiseSource a; private final NoiseSource b; @@ -13,9 +14,9 @@ public final class BlendModule implements NoiseModule { private final Interpolation interpolation; private BlendModule( - @NotNull NoiseSource a, - @NotNull NoiseSource b, - @NotNull NoiseSource controlSource, + NoiseSource a, + NoiseSource b, + NoiseSource controlSource, Interpolation interpolation ) { this.a = a; @@ -44,11 +45,11 @@ public double evaluateNoise(double x, double y, double z, double w) { return interpolation.lerp(controlSource.evaluateNoise(x, y, z, w), a.evaluateNoise(x, y, z, w), b.evaluateNoise(x, y, z, w)); } - @NotNull public static BlendModuleBuilder newBuilder() { return new BlendModuleBuilder(); } + @NullMarked public static final class BlendModuleBuilder implements NoiseSourceBuilder { private NoiseSource a; private NoiseSource b; @@ -64,11 +65,7 @@ private BlendModuleBuilder() { * @param noiseSource the new noise source for the {@link BlendModule}. * @return {@link BlendModuleBuilder} this */ - @NotNull public BlendModuleBuilder setA(NoiseSource noiseSource) { - if (noiseSource == null) { - throw new IllegalArgumentException("First noise source cannot be null."); - } this.a = noiseSource; return this; } @@ -79,11 +76,7 @@ public BlendModuleBuilder setA(NoiseSource noiseSource) { * @param noiseSourceBuilder the new noise source for the {@link BlendModule}. * @return {@link BlendModuleBuilder} this */ - @NotNull public BlendModuleBuilder setA(NoiseSourceBuilder noiseSourceBuilder) { - if (noiseSourceBuilder == null) { - throw new IllegalArgumentException("First noise source cannot be null."); - } this.a = noiseSourceBuilder.build(); return this; } @@ -94,11 +87,7 @@ public BlendModuleBuilder setA(NoiseSourceBuilder noiseSourceBuilder) { * @param noiseSource the new noise source for the {@link BlendModule}. * @return {@link BlendModuleBuilder} this */ - @NotNull public BlendModuleBuilder setB(NoiseSource noiseSource) { - if (noiseSource == null) { - throw new IllegalArgumentException("Second noise source cannot be null."); - } this.b = noiseSource; return this; } @@ -109,11 +98,7 @@ public BlendModuleBuilder setB(NoiseSource noiseSource) { * @param noiseSourceBuilder the new noise source for the {@link BlendModule}. * @return {@link BlendModuleBuilder} this */ - @NotNull public BlendModuleBuilder setB(NoiseSourceBuilder noiseSourceBuilder) { - if (noiseSourceBuilder == null) { - throw new IllegalArgumentException("Second noise source cannot be null."); - } this.b = noiseSourceBuilder.build(); return this; } @@ -124,11 +109,7 @@ public BlendModuleBuilder setB(NoiseSourceBuilder noiseSourceBuilder) { * @param noiseSource the new noise source for the {@link BlendModule}. * @return {@link BlendModuleBuilder} this */ - @NotNull public BlendModuleBuilder setControl(NoiseSource noiseSource) { - if (noiseSource == null) { - throw new IllegalArgumentException("Second noise source cannot be null."); - } this.controlSource = noiseSource; return this; } @@ -139,11 +120,7 @@ public BlendModuleBuilder setControl(NoiseSource noiseSource) { * @param noiseSourceBuilder the new noise source for the {@link BlendModule}. * @return {@link BlendModuleBuilder} this */ - @NotNull public BlendModuleBuilder setControl(NoiseSourceBuilder noiseSourceBuilder) { - if (noiseSourceBuilder == null) { - throw new IllegalArgumentException("Second noise source cannot be null."); - } this.controlSource = noiseSourceBuilder.build(); return this; } @@ -154,26 +131,21 @@ public BlendModuleBuilder setControl(NoiseSourceBuilder noiseSourceBuilder) { * @param interpolation The new {@link Interpolation} for the {@link BlendModule}. * @return {@link BlendModuleBuilder} this */ - @NotNull public BlendModuleBuilder setInterpolation(Interpolation interpolation) { - if (interpolation == null) { - throw new IllegalArgumentException("Interpolation cannot be null."); - } this.interpolation = interpolation; return this; } - - @NotNull + @Override public BlendModule build() { if (a == null) { - throw new IllegalArgumentException("First noise source cannot be null."); + throw new IllegalArgumentException("First noise source must be defined."); } if (b == null) { - throw new IllegalArgumentException("Second noise source cannot be null."); + throw new IllegalArgumentException("Second noise source must be defined."); } if (controlSource == null) { - throw new IllegalArgumentException("Control noise source cannot be null."); + throw new IllegalArgumentException("Control noise source must be defined."); } return new BlendModule(a, b, controlSource, interpolation); } diff --git a/modules/src/main/java/de/articdive/jnoise/modules/combination/CombinationModule.java b/modules/src/main/java/de/articdive/jnoise/modules/combination/CombinationModule.java index e31948c..c182cf2 100644 --- a/modules/src/main/java/de/articdive/jnoise/modules/combination/CombinationModule.java +++ b/modules/src/main/java/de/articdive/jnoise/modules/combination/CombinationModule.java @@ -1,20 +1,21 @@ package de.articdive.jnoise.modules.combination; +import de.articdive.jnoise.core.api.functions.Combiner; import de.articdive.jnoise.core.api.modules.NoiseModule; import de.articdive.jnoise.core.api.pipeline.NoiseSource; import de.articdive.jnoise.core.api.pipeline.NoiseSourceBuilder; -import de.articdive.jnoise.core.api.functions.Combiner; -import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked; +@NullMarked public final class CombinationModule implements NoiseModule { private final NoiseSource a; private final NoiseSource b; private final Combiner combiner; private CombinationModule( - @NotNull NoiseSource a, - @NotNull NoiseSource b, - @NotNull Combiner combiner + NoiseSource a, + NoiseSource b, + Combiner combiner ) { this.a = a; this.b = b; @@ -41,11 +42,11 @@ public double evaluateNoise(double x, double y, double z, double w) { return combiner.applyTo(a.evaluateNoise(x, y, z, w), b.evaluateNoise(x, y, z, w)); } - @NotNull public static CombinationModuleBuilder newBuilder() { return new CombinationModuleBuilder(); } + @NullMarked public static final class CombinationModuleBuilder implements NoiseSourceBuilder { private NoiseSource a; private NoiseSource b; @@ -60,11 +61,7 @@ private CombinationModuleBuilder() { * @param noiseSource the new noise source for the {@link CombinationModule}. * @return {@link CombinationModuleBuilder} this */ - @NotNull public CombinationModuleBuilder setA(NoiseSource noiseSource) { - if (noiseSource == null) { - throw new IllegalArgumentException("First noise source cannot be null."); - } this.a = noiseSource; return this; } @@ -75,11 +72,7 @@ public CombinationModuleBuilder setA(NoiseSource noiseSource) { * @param noiseSourceBuilder the new noise source for the {@link CombinationModule}. * @return {@link CombinationModuleBuilder} this */ - @NotNull public CombinationModuleBuilder setA(NoiseSourceBuilder noiseSourceBuilder) { - if (noiseSourceBuilder == null) { - throw new IllegalArgumentException("First noise source cannot be null."); - } this.a = noiseSourceBuilder.build(); return this; } @@ -90,11 +83,7 @@ public CombinationModuleBuilder setA(NoiseSourceBuilder noiseSourceBuilder) { * @param noiseSource the new noise source for the {@link CombinationModule}. * @return {@link CombinationModuleBuilder} this */ - @NotNull public CombinationModuleBuilder setB(NoiseSource noiseSource) { - if (noiseSource == null) { - throw new IllegalArgumentException("Second noise source cannot be null."); - } this.b = noiseSource; return this; } @@ -105,11 +94,7 @@ public CombinationModuleBuilder setB(NoiseSource noiseSource) { * @param noiseSourceBuilder the new noise source for the {@link CombinationModule}. * @return {@link CombinationModuleBuilder} this */ - @NotNull public CombinationModuleBuilder setB(NoiseSourceBuilder noiseSourceBuilder) { - if (noiseSourceBuilder == null) { - throw new IllegalArgumentException("Second noise source cannot be null."); - } this.b = noiseSourceBuilder.build(); return this; } @@ -120,23 +105,18 @@ public CombinationModuleBuilder setB(NoiseSourceBuilder noiseSourceBuilder) { * @param combiner the new {@link Combiner} for the {@link CombinationModule}. * @return {@link CombinationModuleBuilder} this */ - @NotNull public CombinationModuleBuilder setCombiner(Combiner combiner) { - if (combiner == null) { - throw new IllegalArgumentException("Combiner cannot be null."); - } this.combiner = combiner; return this; } - - @NotNull + @Override public CombinationModule build() { if (a == null) { - throw new IllegalArgumentException("First noise source cannot be null."); + throw new IllegalArgumentException("First noise source must be defined."); } if (b == null) { - throw new IllegalArgumentException("Second noise source cannot be null."); + throw new IllegalArgumentException("Second noise source must be defined."); } return new CombinationModule(a, b, combiner); } diff --git a/modules/src/main/java/de/articdive/jnoise/modules/octavation/OctavationModule.java b/modules/src/main/java/de/articdive/jnoise/modules/octavation/OctavationModule.java index e1d18b9..88f9184 100644 --- a/modules/src/main/java/de/articdive/jnoise/modules/octavation/OctavationModule.java +++ b/modules/src/main/java/de/articdive/jnoise/modules/octavation/OctavationModule.java @@ -5,8 +5,9 @@ import de.articdive.jnoise.core.api.pipeline.NoiseSource; import de.articdive.jnoise.core.api.pipeline.NoiseSourceBuilder; import de.articdive.jnoise.modules.octavation.fractal_functions.FractalFunction; -import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked; +@NullMarked public final class OctavationModule implements NoiseModule { private final NoiseSource noiseSource; private final int octaves; @@ -18,11 +19,11 @@ public final class OctavationModule implements NoiseModule { private final double fractalBounding; private OctavationModule( - @NotNull NoiseSource noiseSource, + NoiseSource noiseSource, int octaves, double gain, double lacunarity, - @NotNull FractalFunction fractalFunction, + FractalFunction fractalFunction, boolean incrementSeed ) { this.noiseSource = noiseSource; @@ -132,11 +133,11 @@ public double evaluateNoise(double x, double y, double z, double w) { return output / fractalBounding; } - @NotNull public static OctavationModuleBuilder newBuilder() { return new OctavationModuleBuilder(); } + @NullMarked public static final class OctavationModuleBuilder implements NoiseSourceBuilder { private NoiseSource noiseSource; private int octaves = 4; @@ -154,11 +155,7 @@ private OctavationModuleBuilder() { * @param noiseSource the new noise source for the {@link OctavationModule}. * @return {@link OctavationModuleBuilder} this */ - @NotNull public OctavationModuleBuilder setNoiseSource(NoiseSource noiseSource) { - if (noiseSource == null) { - throw new IllegalArgumentException("Noise source cannot be null."); - } this.noiseSource = noiseSource; return this; } @@ -169,11 +166,7 @@ public OctavationModuleBuilder setNoiseSource(NoiseSource noiseSource) { * @param noiseSourceBuilder the new noise source for the {@link OctavationModule}. * @return {@link OctavationModuleBuilder} this */ - @NotNull public OctavationModuleBuilder setNoiseSource(NoiseSourceBuilder noiseSourceBuilder) { - if (noiseSourceBuilder == null) { - throw new IllegalArgumentException("Noise source cannot be null."); - } this.noiseSource = noiseSourceBuilder.build(); return this; } @@ -184,7 +177,6 @@ public OctavationModuleBuilder setNoiseSource(NoiseSourceBuilder noiseSourceBuil * @param octaves the new amount of octaves for the {@link OctavationModule}. * @return {@link OctavationModuleBuilder} this */ - @NotNull public OctavationModuleBuilder setOctaves(int octaves) { if (octaves <= 0) { throw new IllegalArgumentException("The amount of octaves must be a non-zero positive integer."); @@ -200,7 +192,6 @@ public OctavationModuleBuilder setOctaves(int octaves) { * @return {@link OctavationModuleBuilder} this * @deprecated Use {@link #setGain} - Internals have not changed. */ - @NotNull @Deprecated public OctavationModuleBuilder setPersistence(double persistence) { return setGain(persistence); @@ -212,7 +203,6 @@ public OctavationModuleBuilder setPersistence(double persistence) { * @param gain the new gain for the {@link OctavationModule}. * @return {@link OctavationModuleBuilder} this */ - @NotNull public OctavationModuleBuilder setGain(double gain) { if (gain <= 0) { throw new IllegalArgumentException("Gain must be a non-zero positive value."); @@ -227,7 +217,6 @@ public OctavationModuleBuilder setGain(double gain) { * @param lacunarity the new lacunarity for the {@link OctavationModule}. * @return {@link OctavationModuleBuilder} this */ - @NotNull public OctavationModuleBuilder setLacunarity(double lacunarity) { if (lacunarity <= 0) { throw new IllegalArgumentException("Lacunarity must be a non-zero positive value."); @@ -242,11 +231,7 @@ public OctavationModuleBuilder setLacunarity(double lacunarity) { * @param fractalFunction the new {@link FractalFunction} for the {@link OctavationModule}. * @return {@link OctavationModuleBuilder} this */ - @NotNull public OctavationModuleBuilder setFractalFunction(FractalFunction fractalFunction) { - if (fractalFunction == null) { - throw new IllegalArgumentException("Fractal function cannot be null."); - } this.fractalFunction = fractalFunction; return this; } @@ -257,16 +242,15 @@ public OctavationModuleBuilder setFractalFunction(FractalFunction fractalFunctio * @param incrementSeed true if seed should increment each octave for the {@link OctavationModule}. * @return {@link OctavationModuleBuilder} this */ - @NotNull public OctavationModuleBuilder setIncrementSeed(boolean incrementSeed) { this.incrementSeed = incrementSeed; return this; } - @NotNull + @Override public OctavationModule build() { if (noiseSource == null) { - throw new IllegalArgumentException("Noise source has not been defined."); + throw new IllegalArgumentException("Noise source must be defined."); } if (incrementSeed && !(noiseSource instanceof SeededNoiseGenerator)) { throw new IllegalArgumentException("Noise source does not have a seed, hence incrementSeed cannot be true!"); diff --git a/modules/src/main/java/de/articdive/jnoise/modules/selection/SelectionModule.java b/modules/src/main/java/de/articdive/jnoise/modules/selection/SelectionModule.java index 3e29e14..2f99cda 100644 --- a/modules/src/main/java/de/articdive/jnoise/modules/selection/SelectionModule.java +++ b/modules/src/main/java/de/articdive/jnoise/modules/selection/SelectionModule.java @@ -3,8 +3,9 @@ import de.articdive.jnoise.core.api.modules.NoiseModule; import de.articdive.jnoise.core.api.pipeline.NoiseSource; import de.articdive.jnoise.core.api.pipeline.NoiseSourceBuilder; -import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked; +@NullMarked public final class SelectionModule implements NoiseModule { private final NoiseSource a; private final NoiseSource b; @@ -12,9 +13,9 @@ public final class SelectionModule implements NoiseModule { private final double boundary; private SelectionModule( - @NotNull NoiseSource a, - @NotNull NoiseSource b, - @NotNull NoiseSource controlSource, + NoiseSource a, + NoiseSource b, + NoiseSource controlSource, double boundary ) { this.a = a; @@ -59,11 +60,11 @@ public double evaluateNoise(double x, double y, double z, double w) { } } - @NotNull public static SelectionModuleBuilder newBuilder() { return new SelectionModuleBuilder(); } + @NullMarked public static final class SelectionModuleBuilder implements NoiseSourceBuilder { private NoiseSource a; private NoiseSource b; @@ -79,11 +80,7 @@ private SelectionModuleBuilder() { * @param noiseSource the new noise source for the {@link SelectionModule}. * @return {@link SelectionModuleBuilder} this */ - @NotNull public SelectionModuleBuilder setA(NoiseSource noiseSource) { - if (noiseSource == null) { - throw new IllegalArgumentException("First noise source cannot be null."); - } this.a = noiseSource; return this; } @@ -94,11 +91,7 @@ public SelectionModuleBuilder setA(NoiseSource noiseSource) { * @param noiseSourceBuilder the new noise source for the {@link SelectionModule}. * @return {@link SelectionModuleBuilder} this */ - @NotNull public SelectionModuleBuilder setA(NoiseSourceBuilder noiseSourceBuilder) { - if (noiseSourceBuilder == null) { - throw new IllegalArgumentException("First noise source cannot be null."); - } this.a = noiseSourceBuilder.build(); return this; } @@ -109,11 +102,7 @@ public SelectionModuleBuilder setA(NoiseSourceBuilder noiseSourceBuilder) { * @param noiseSource the new noise source for the {@link SelectionModule}. * @return {@link SelectionModuleBuilder} this */ - @NotNull public SelectionModuleBuilder setB(NoiseSource noiseSource) { - if (noiseSource == null) { - throw new IllegalArgumentException("Second noise source cannot be null."); - } this.b = noiseSource; return this; } @@ -124,11 +113,7 @@ public SelectionModuleBuilder setB(NoiseSource noiseSource) { * @param noiseSourceBuilder the new noise source for the {@link SelectionModule}. * @return {@link SelectionModuleBuilder} this */ - @NotNull public SelectionModuleBuilder setB(NoiseSourceBuilder noiseSourceBuilder) { - if (noiseSourceBuilder == null) { - throw new IllegalArgumentException("Second noise source cannot be null."); - } this.b = noiseSourceBuilder.build(); return this; } @@ -139,11 +124,7 @@ public SelectionModuleBuilder setB(NoiseSourceBuilder noiseSourceBuilder) { * @param noiseSource the new noise source for the {@link SelectionModule}. * @return {@link SelectionModuleBuilder} this */ - @NotNull public SelectionModuleBuilder setControl(NoiseSource noiseSource) { - if (noiseSource == null) { - throw new IllegalArgumentException("Second noise source cannot be null."); - } this.controlSource = noiseSource; return this; } @@ -154,11 +135,7 @@ public SelectionModuleBuilder setControl(NoiseSource noiseSource) { * @param noiseSourceBuilder the new noise source for the {@link SelectionModule}. * @return {@link SelectionModuleBuilder} this */ - @NotNull public SelectionModuleBuilder setControl(NoiseSourceBuilder noiseSourceBuilder) { - if (noiseSourceBuilder == null) { - throw new IllegalArgumentException("Second noise source cannot be null."); - } this.controlSource = noiseSourceBuilder.build(); return this; } @@ -169,23 +146,21 @@ public SelectionModuleBuilder setControl(NoiseSourceBuilder noiseSourceBuilder) * @param boundary the new boundary for the {@link SelectionModule}. * @return {@link SelectionModuleBuilder} this */ - @NotNull public SelectionModuleBuilder setBoundary(double boundary) { this.boundary = boundary; return this; } - - @NotNull + @Override public SelectionModule build() { if (a == null) { - throw new IllegalArgumentException("First noise source cannot be null."); + throw new IllegalArgumentException("First noise source must be defined."); } if (b == null) { - throw new IllegalArgumentException("Second noise source cannot be null."); + throw new IllegalArgumentException("Second noise source must be defined."); } if (controlSource == null) { - throw new IllegalArgumentException("Control noise source cannot be null."); + throw new IllegalArgumentException("Control noise source must be defined."); } return new SelectionModule(a, b, controlSource, boundary); } diff --git a/pipeline/src/main/java/de/articdive/jnoise/pipeline/JNoise.java b/pipeline/src/main/java/de/articdive/jnoise/pipeline/JNoise.java index 081542d..bef1520 100644 --- a/pipeline/src/main/java/de/articdive/jnoise/pipeline/JNoise.java +++ b/pipeline/src/main/java/de/articdive/jnoise/pipeline/JNoise.java @@ -34,7 +34,7 @@ import de.articdive.jnoise.modules.octavation.OctavationModule; import de.articdive.jnoise.modules.octavation.fractal_functions.FractalFunction; import de.articdive.jnoise.transformers.scale.ScaleTransformer; -import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked; import java.util.ArrayList; import java.util.LinkedList; @@ -46,6 +46,7 @@ * * @author Articdive */ +@NullMarked public class JNoise implements NoiseSource { protected final SimpleTransformer[] simpleTransformers; protected final DetailedTransformer[] detailedTransformers; @@ -53,10 +54,10 @@ public class JNoise implements NoiseSource { private final NoiseSource source; JNoise( - @NotNull SimpleTransformer[] simpleTransformers, - @NotNull DetailedTransformer[] detailedTransformers, - @NotNull NoiseSource source, - @NotNull NoiseModifier[] modifiers + SimpleTransformer[] simpleTransformers, + DetailedTransformer[] detailedTransformers, + NoiseSource source, + NoiseModifier[] modifiers ) { this.simpleTransformers = simpleTransformers; this.detailedTransformers = detailedTransformers; @@ -140,12 +141,12 @@ public double evaluateNoise(double x, double y, double z, double w) { } - @NotNull public static JNoiseBuilder newBuilder() { return new JNoiseBuilder<>(); } - @SuppressWarnings("unchecked") + @SuppressWarnings({"unchecked", "unused"}) + @NullMarked public static final class JNoiseBuilder implements NoiseSourceBuilder { private final List simpleTransformers = new ArrayList<>(); private final List detailedTransformers = new ArrayList<>(); @@ -157,51 +158,44 @@ private JNoiseBuilder() { } // SIMPLE TRANSFORMERS - @NotNull - public JNoiseBuilder addSimpleTransformer(@NotNull SimpleTransformer transformer) { + public JNoiseBuilder addSimpleTransformer(SimpleTransformer transformer) { simpleTransformers.add(transformer); return this; } - @NotNull public JNoiseBuilder scale(double factor) { simpleTransformers.add(new ScaleTransformer(factor)); return this; } // DETAILED TRANSFORMERS - @NotNull - public JNoiseBuilder addDetailedTransformer(@NotNull DetailedTransformer transformer) { + public JNoiseBuilder addDetailedTransformer(DetailedTransformer transformer) { detailedTransformers.add(transformer); return this; } // SOURCES - @NotNull - public JNoiseBuilder setNoiseSource(@NotNull NoiseSource source) { + public JNoiseBuilder setNoiseSource(NoiseSource source) { this.source = source; return this; } - @NotNull - public JNoiseBuilder setNoiseSource(@NotNull NoiseSourceBuilder sourceBuilder) { + public JNoiseBuilder setNoiseSource(NoiseSourceBuilder sourceBuilder) { this.source = sourceBuilder.build(); return this; } - @NotNull - public JNoiseBuilder setNoiseSource(@NotNull ExplicitNoiseSource noiseGenerator) { + public JNoiseBuilder setNoiseSource(ExplicitNoiseSource noiseGenerator) { this.source = noiseGenerator; return (JNoiseBuilder) this; } - @NotNull public JNoiseBuilder octavation( - @NotNull NoiseSource a, + NoiseSource a, int octaves, double persistence, double lacunarity, - @NotNull FractalFunction fractalFunction, + FractalFunction fractalFunction, boolean incrementSeed) { return setNoiseSource(OctavationModule.newBuilder() .setNoiseSource(a) @@ -214,22 +208,19 @@ public JNoiseBuilder octavation( ); } - @NotNull - public JNoiseBuilder octavation(@NotNull OctavationModule.OctavationModuleBuilder builder) { + public JNoiseBuilder octavation(OctavationModule.OctavationModuleBuilder builder) { return setNoiseSource(builder); } - @NotNull - public JNoiseBuilder octavation(@NotNull OctavationModule module) { + public JNoiseBuilder octavation(OctavationModule module) { return setNoiseSource(module); } - @NotNull public JNoiseBuilder octavate( int octaves, double gain, double lacunarity, - @NotNull FractalFunction fractalFunction, + FractalFunction fractalFunction, boolean incrementSeed) { if (source == null) { throw new IllegalArgumentException("Cannot octavate an empty noise source."); @@ -245,8 +236,7 @@ public JNoiseBuilder octavate( ); } - @NotNull - public JNoiseBuilder combination(@NotNull NoiseSource a, @NotNull NoiseSource b, @NotNull Combiner combiner) { + public JNoiseBuilder combination(NoiseSource a, NoiseSource b, Combiner combiner) { return setNoiseSource(CombinationModule.newBuilder() .setA(a) .setB(b) @@ -255,18 +245,15 @@ public JNoiseBuilder combination(@NotNull NoiseSource a, @NotNull NoiseSource ); } - @NotNull - public JNoiseBuilder combination(@NotNull CombinationModule.CombinationModuleBuilder builder) { + public JNoiseBuilder combination(CombinationModule.CombinationModuleBuilder builder) { return setNoiseSource(builder); } - @NotNull - public JNoiseBuilder combination(@NotNull CombinationModule module) { + public JNoiseBuilder combination(CombinationModule module) { return setNoiseSource(module); } - @NotNull - public JNoiseBuilder combine(@NotNull NoiseSource b, @NotNull Combiner combiner) { + public JNoiseBuilder combine(NoiseSource b, Combiner combiner) { if (source == null) { throw new IllegalArgumentException("Cannot combine to an empty noise source."); } @@ -278,29 +265,25 @@ public JNoiseBuilder combine(@NotNull NoiseSource b, @NotNull Combiner combin ); } - @NotNull - public JNoiseBuilder perlin(long seed, @NotNull Interpolation interpolation, @NotNull FadeFunction fadeFunction) { + public JNoiseBuilder perlin(long seed, Interpolation interpolation, FadeFunction fadeFunction) { return setNoiseSource( PerlinNoiseGenerator.newBuilder().setSeed(seed).setInterpolation(interpolation).setFadeFunction(fadeFunction).build() ); } - @NotNull - public JNoiseBuilder perlin(@NotNull PerlinNoiseGenerator.PerlinNoiseBuilder builder) { + public JNoiseBuilder perlin(PerlinNoiseGenerator.PerlinNoiseBuilder builder) { return setNoiseSource(builder); } - @NotNull - public JNoiseBuilder perlin(@NotNull PerlinNoiseGenerator generator) { + public JNoiseBuilder perlin(PerlinNoiseGenerator generator) { return setNoiseSource(generator); } - @NotNull public JNoiseBuilder fastSimplex( long seed, - @NotNull Simplex2DVariant variant2D, - @NotNull Simplex3DVariant variant3D, - @NotNull Simplex4DVariant variant4D + Simplex2DVariant variant2D, + Simplex3DVariant variant3D, + Simplex4DVariant variant4D ) { return setNoiseSource( FastSimplexNoiseGenerator.newBuilder().setSeed(seed) @@ -311,22 +294,19 @@ public JNoiseBuilder fastSimplex( ); } - @NotNull - public JNoiseBuilder fastSimplex(@NotNull FastSimplexNoiseGenerator.FastSimplexNoiseBuilder builder) { + public JNoiseBuilder fastSimplex(FastSimplexNoiseGenerator.FastSimplexNoiseBuilder builder) { return setNoiseSource(builder); } - @NotNull - public JNoiseBuilder fastSimplex(@NotNull FastSimplexNoiseGenerator generator) { + public JNoiseBuilder fastSimplex(FastSimplexNoiseGenerator generator) { return setNoiseSource(generator); } - @NotNull public JNoiseBuilder superSimplex( long seed, - @NotNull Simplex2DVariant variant2D, - @NotNull Simplex3DVariant variant3D, - @NotNull Simplex4DVariant variant4D + Simplex2DVariant variant2D, + Simplex3DVariant variant3D, + Simplex4DVariant variant4D ) { return setNoiseSource(SuperSimplexNoiseGenerator.newBuilder().setSeed(seed) .setVariant2D(variant2D) @@ -336,121 +316,99 @@ public JNoiseBuilder superSimplex( ); } - @NotNull - public JNoiseBuilder superSimplex(@NotNull SuperSimplexNoiseGenerator.SuperSimplexNoiseBuilder builder) { + public JNoiseBuilder superSimplex(SuperSimplexNoiseGenerator.SuperSimplexNoiseBuilder builder) { return setNoiseSource(builder); } - @NotNull - public JNoiseBuilder superSimplex(@NotNull SuperSimplexNoiseGenerator generator) { + public JNoiseBuilder superSimplex(SuperSimplexNoiseGenerator generator) { return setNoiseSource(generator); } - @NotNull - public JNoiseBuilder value(long seed, @NotNull Interpolation interpolation, @NotNull FadeFunction fadeFunction) { + public JNoiseBuilder value(long seed, Interpolation interpolation, FadeFunction fadeFunction) { return setNoiseSource( ValueNoiseGenerator.newBuilder().setSeed(seed).setInterpolation(interpolation).setFadeFunction(fadeFunction).build() ); } - @NotNull - public JNoiseBuilder value(@NotNull ValueNoiseGenerator.ValueNoiseBuilder builder) { + public JNoiseBuilder value(ValueNoiseGenerator.ValueNoiseBuilder builder) { return setNoiseSource(builder); } - @NotNull - public JNoiseBuilder value(@NotNull ValueNoiseGenerator generator) { + public JNoiseBuilder value(ValueNoiseGenerator generator) { return setNoiseSource(generator); } - @NotNull public JNoiseBuilder white(long seed) { return setNoiseSource(WhiteNoiseGenerator.newBuilder().setSeed(seed).build()); } - @NotNull - public JNoiseBuilder white(@NotNull WhiteNoiseGenerator.WhiteNoiseBuilder builder) { + public JNoiseBuilder white(WhiteNoiseGenerator.WhiteNoiseBuilder builder) { return setNoiseSource(builder); } - @NotNull - public JNoiseBuilder white(@NotNull WhiteNoiseGenerator generator) { + public JNoiseBuilder white(WhiteNoiseGenerator generator) { return setNoiseSource(generator); } - @NotNull public JNoiseBuilder gaussianWhite(long seed) { return setNoiseSource(GaussianWhiteNoiseGenerator.newBuilder().setSeed(seed).build()); } - @NotNull public JNoiseBuilder gaussianWhite(GaussianWhiteNoiseGenerator.GaussianWhiteNoiseBuilder builder) { return setNoiseSource(builder); } - @NotNull public JNoiseBuilder gaussianWhite(GaussianWhiteNoiseGenerator generator) { return setNoiseSource(generator); } - @NotNull - public JNoiseBuilder> worley(long seed, @NotNull DistanceFunction distanceFunction, @NotNull IntToLongFunction fpFunction) { + public JNoiseBuilder> worley(long seed, DistanceFunction distanceFunction, IntToLongFunction fpFunction) { this.source = WorleyNoiseGenerator.newBuilder().setSeed(seed).setDistanceFunction(distanceFunction).setFeaturePointAmountFunction(fpFunction).build(); return (JNoiseBuilder>) this; } - @NotNull - public JNoiseBuilder> worley(@NotNull WorleyNoiseGenerator.WorleyNoiseBuilder builder) { + public JNoiseBuilder> worley(WorleyNoiseGenerator.WorleyNoiseBuilder builder) { this.source = builder.build(); return (JNoiseBuilder>) this; } - @NotNull - public JNoiseBuilder> worley(@NotNull WorleyNoiseGenerator generator) { + public JNoiseBuilder> worley(WorleyNoiseGenerator generator) { this.source = generator; return (JNoiseBuilder>) this; } - @NotNull public JNoiseBuilder constant(double constant) { return setNoiseSource(ConstantNoiseGenerator.newBuilder().setConstant(constant).build()); } - @NotNull - public JNoiseBuilder constant(@NotNull ConstantNoiseGenerator.ConstantNoiseBuilder builder) { + public JNoiseBuilder constant(ConstantNoiseGenerator.ConstantNoiseBuilder builder) { return setNoiseSource(builder); } - @NotNull - public JNoiseBuilder constant(@NotNull ConstantNoiseGenerator generator) { + public JNoiseBuilder constant(ConstantNoiseGenerator generator) { return setNoiseSource(generator); } // MODIFIERS - @NotNull - public JNoiseBuilder addModifier(@NotNull NoiseModifier noiseModifier) { + public JNoiseBuilder addModifier(NoiseModifier noiseModifier) { modifiers.add(noiseModifier); return this; } - @NotNull public JNoiseBuilder abs() { return addModifier(new AbsoluteValueModifier()); } - @NotNull public JNoiseBuilder clamp(double a, double b) { return addModifier(new ClampModifier(a, b)); } - @NotNull public JNoiseBuilder invert() { return addModifier(new InvertModifier()); } @Override - @NotNull public JNoise build() { if (source == null) { throw new IllegalArgumentException("Source must be defined."); @@ -463,7 +421,6 @@ public JNoise build() { ); } - @NotNull public JNoiseDetailed buildDetailed() { if (source == null) { throw new IllegalArgumentException("Source must be defined."); diff --git a/pipeline/src/main/java/de/articdive/jnoise/pipeline/JNoiseDetailed.java b/pipeline/src/main/java/de/articdive/jnoise/pipeline/JNoiseDetailed.java index 56f1ec5..a368428 100644 --- a/pipeline/src/main/java/de/articdive/jnoise/pipeline/JNoiseDetailed.java +++ b/pipeline/src/main/java/de/articdive/jnoise/pipeline/JNoiseDetailed.java @@ -8,28 +8,28 @@ import de.articdive.jnoise.core.util.vectors.Vector2D; import de.articdive.jnoise.core.util.vectors.Vector3D; import de.articdive.jnoise.core.util.vectors.Vector4D; -import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked; /** * Secondary class for the JNoise Pipeline for handling {@link ExplicitNoiseSource}s and their {@link NoiseResult}s. * * @author Articdive */ +@NullMarked public class JNoiseDetailed extends JNoise implements ExplicitNoiseSource { private final ExplicitNoiseSource source; JNoiseDetailed( - @NotNull SimpleTransformer[] simpleTransformers, - @NotNull DetailedTransformer[] detailedTransformers, - @NotNull ExplicitNoiseSource source, - @NotNull NoiseModifier[] modifiers + SimpleTransformer[] simpleTransformers, + DetailedTransformer[] detailedTransformers, + ExplicitNoiseSource source, + NoiseModifier[] modifiers ) { super(simpleTransformers, detailedTransformers, source, modifiers); this.source = source; } @Override - @NotNull public NR evaluateNoiseResult(double x) { for (SimpleTransformer simpleTransformer : simpleTransformers) { x = simpleTransformer.transformX(x); @@ -45,7 +45,6 @@ public NR evaluateNoiseResult(double x) { } @Override - @NotNull public NR evaluateNoiseResult(double x, double y) { for (SimpleTransformer simpleTransformer : simpleTransformers) { x = simpleTransformer.transformX(x); @@ -64,7 +63,6 @@ public NR evaluateNoiseResult(double x, double y) { } @Override - @NotNull public NR evaluateNoiseResult(double x, double y, double z) { for (SimpleTransformer simpleTransformer : simpleTransformers) { x = simpleTransformer.transformX(x); @@ -85,7 +83,6 @@ public NR evaluateNoiseResult(double x, double y, double z) { } @Override - @NotNull public NR evaluateNoiseResult(double x, double y, double z, double w) { for (SimpleTransformer simpleTransformer : simpleTransformers) { x = simpleTransformer.transformX(x); diff --git a/transformers/src/main/java/de/articdive/jnoise/transformers/domain_warp/DomainWarpTransformer.java b/transformers/src/main/java/de/articdive/jnoise/transformers/domain_warp/DomainWarpTransformer.java index 5a9108c..a08cede 100644 --- a/transformers/src/main/java/de/articdive/jnoise/transformers/domain_warp/DomainWarpTransformer.java +++ b/transformers/src/main/java/de/articdive/jnoise/transformers/domain_warp/DomainWarpTransformer.java @@ -6,13 +6,14 @@ import de.articdive.jnoise.core.util.vectors.Vector2D; import de.articdive.jnoise.core.util.vectors.Vector3D; import de.articdive.jnoise.core.util.vectors.Vector4D; -import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked; /** * Domain warping transformer. This will allow for pinching, streching, twisting, bending and basically any deformation on noise. * * @author Articdive */ +@NullMarked public final class DomainWarpTransformer implements DetailedTransformer { private final NoiseSource noiseSource; private final Vector4D warpingVector; @@ -22,11 +23,11 @@ public final class DomainWarpTransformer implements DetailedTransformer { private DomainWarpTransformer( - @NotNull NoiseSource noiseSource, - @NotNull Vector4D warpingVector, - @NotNull Vector2D offset2D, - @NotNull Vector3D[] offset3D, - @NotNull Vector4D[] offset4D + NoiseSource noiseSource, + Vector4D warpingVector, + Vector2D offset2D, + Vector3D[] offset3D, + Vector4D[] offset4D ) { this.noiseSource = noiseSource; this.warpingVector = warpingVector; @@ -41,7 +42,7 @@ public double transform(double x) { } @Override - public @NotNull Vector2D transform(double x, double y) { + public Vector2D transform(double x, double y) { double q0 = noiseSource.evaluateNoise(x, y); double q1 = noiseSource.evaluateNoise(x + offset2D.x(), y + offset2D.y()); @@ -49,7 +50,7 @@ public double transform(double x) { } @Override - public @NotNull Vector3D transform(double x, double y, double z) { + public Vector3D transform(double x, double y, double z) { Vector3D offset0 = offset3D[0]; Vector3D offset1 = offset3D[1]; @@ -61,7 +62,7 @@ public double transform(double x) { } @Override - public @NotNull Vector4D transform(double x, double y, double z, double w) { + public Vector4D transform(double x, double y, double z, double w) { Vector4D offset0 = offset4D[0]; Vector4D offset1 = offset4D[1]; Vector4D offset2 = offset4D[2]; @@ -79,7 +80,6 @@ public double transform(double x) { * * @return {@link DomainWarpTransformerBuilder}. */ - @NotNull public static DomainWarpTransformerBuilder newBuilder() { return new DomainWarpTransformerBuilder(); } @@ -87,6 +87,7 @@ public static DomainWarpTransformerBuilder newBuilder() { /** * Builder for the {@link DomainWarpTransformer}. */ + @NullMarked public static final class DomainWarpTransformerBuilder { private NoiseSource noiseSource; private Vector4D warpingVector = new Vector4D(4, 4, 4, 4); @@ -104,11 +105,7 @@ private DomainWarpTransformerBuilder() { * @param noiseSource the new noise source for the {@link DomainWarpTransformer}. * @return {@link DomainWarpTransformerBuilder} this */ - @NotNull public DomainWarpTransformerBuilder setNoiseSource(NoiseSource noiseSource) { - if (noiseSource == null) { - throw new IllegalArgumentException("Noise source cannot be null."); - } this.noiseSource = noiseSource; return this; } @@ -119,11 +116,7 @@ public DomainWarpTransformerBuilder setNoiseSource(NoiseSource noiseSource) { * @param noiseSourceBuilder the new noise source for the {@link DomainWarpTransformer}. * @return {@link DomainWarpTransformerBuilder} this */ - @NotNull public DomainWarpTransformerBuilder setNoiseSource(NoiseSourceBuilder noiseSourceBuilder) { - if (noiseSourceBuilder == null) { - throw new IllegalArgumentException("Noise source cannot be null."); - } this.noiseSource = noiseSourceBuilder.build(); return this; } @@ -134,11 +127,7 @@ public DomainWarpTransformerBuilder setNoiseSource(NoiseSourceBuilder noiseSourc * @param warpingVector {@link Vector4D} the new warping vector for the {@link DomainWarpTransformer}. * @return {@link DomainWarpTransformerBuilder} this */ - @NotNull public DomainWarpTransformerBuilder setWarpingVector(Vector4D warpingVector) { - if (warpingVector == null) { - throw new IllegalArgumentException("Warping vector cannot be null."); - } this.warpingVector = warpingVector; return this; } @@ -149,11 +138,7 @@ public DomainWarpTransformerBuilder setWarpingVector(Vector4D warpingVector) { * @param offset2D {@link Vector2D} the new 2D offset for the {@link DomainWarpTransformer}. * @return {@link DomainWarpTransformerBuilder} this */ - @NotNull public DomainWarpTransformerBuilder set2DOffset(Vector2D offset2D) { - if (offset2D == null) { - throw new IllegalArgumentException("2D Offset cannot be null."); - } this.offset2D = offset2D; return this; } @@ -165,17 +150,10 @@ public DomainWarpTransformerBuilder set2DOffset(Vector2D offset2D) { * @param offset3D {@link Vector3D} the new 3D offset for the {@link DomainWarpTransformer}. * @return {@link DomainWarpTransformerBuilder} this */ - @NotNull public DomainWarpTransformerBuilder set3DOffset(Vector3D... offset3D) { - if (offset3D == null) { - throw new IllegalArgumentException("3D Offset cannot be null."); - } if (offset3D.length < 2) { throw new IllegalArgumentException("3D Offset must have length 2 (Elements beyond index 1 will be ignored)."); } - if (offset3D[0] == null || offset3D[1] == null) { - throw new IllegalArgumentException("3D Offset must contain non-null values."); - } this.offset3D = new Vector3D[]{offset3D[0], offset3D[1]}; return this; } @@ -187,16 +165,9 @@ public DomainWarpTransformerBuilder set3DOffset(Vector3D... offset3D) { * @param offset4D {@link Vector4D} the new 4D offset for the {@link DomainWarpTransformer}. * @return {@link DomainWarpTransformerBuilder} this */ - @NotNull public DomainWarpTransformerBuilder set4DOffset(Vector4D... offset4D) { - if (offset4D == null) { - throw new IllegalArgumentException("4D Offset cannot be null."); - } - if (offset4D.length < 2) { - throw new IllegalArgumentException("4D Offset must have length 2 (Elements beyond index 1 will be ignored)."); - } - if (offset4D[0] == null || offset4D[1] == null || offset4D[2] == null) { - throw new IllegalArgumentException("4D Offset must contain non-null values."); + if (offset4D.length < 3) { + throw new IllegalArgumentException("4D Offset must have length 3 (Elements beyond index 2 will be ignored)."); } this.offset4D = new Vector4D[]{offset4D[0], offset4D[1], offset4D[2]}; return this; @@ -207,10 +178,9 @@ public DomainWarpTransformerBuilder set4DOffset(Vector4D... offset4D) { * * @return the built {@link DomainWarpTransformer} or throws an error if misconfigured. */ - @NotNull public DomainWarpTransformer build() { if (noiseSource == null) { - throw new IllegalArgumentException("Noise source has not been defined."); + throw new IllegalArgumentException("Noise source must be defined."); } return new DomainWarpTransformer(noiseSource, warpingVector, offset2D, offset3D, offset4D); } diff --git a/transformers/src/main/java/de/articdive/jnoise/transformers/scale/ScaleTransformer.java b/transformers/src/main/java/de/articdive/jnoise/transformers/scale/ScaleTransformer.java index 252ea7c..efd4c02 100644 --- a/transformers/src/main/java/de/articdive/jnoise/transformers/scale/ScaleTransformer.java +++ b/transformers/src/main/java/de/articdive/jnoise/transformers/scale/ScaleTransformer.java @@ -2,13 +2,14 @@ import de.articdive.jnoise.core.api.transformers.SimpleTransformer; import de.articdive.jnoise.core.util.vectors.Vector4D; -import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked; /** * Simplistic Scale transformer (Frequency transformer) that multiplies each coordinate part by the specified scale value. * * @author Articdive */ +@NullMarked public final class ScaleTransformer implements SimpleTransformer { private final Vector4D scale; @@ -22,7 +23,7 @@ public ScaleTransformer(double scale) { /** * @param scaleVector Vector containing the scale value for all dimensions. */ - public ScaleTransformer(@NotNull Vector4D scaleVector) { + public ScaleTransformer(Vector4D scaleVector) { this(scaleVector.x(), scaleVector.y(), scaleVector.z(), scaleVector.w()); }