Skip to content

Commit

Permalink
Update dependencies, gradle and switch to JSpecify.
Browse files Browse the repository at this point in the history
  • Loading branch information
Articdive committed Oct 15, 2023
1 parent 093b44d commit 61ab6c9
Show file tree
Hide file tree
Showing 32 changed files with 195 additions and 425 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
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.
*
* @param <NR> {@link NoiseResult} class
* @author Articdive
*/
@NullMarked
public interface SeededExplicitNoiseGenerator<NR extends NoiseResult> extends ExplicitNoiseGenerator<NR>, SeededNoiseGenerator {
/**
* Evaluates noise at a 1D point.
Expand All @@ -16,7 +17,6 @@ public interface SeededExplicitNoiseGenerator<NR extends NoiseResult> 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);

/**
Expand All @@ -27,7 +27,6 @@ public interface SeededExplicitNoiseGenerator<NR extends NoiseResult> 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);

/**
Expand All @@ -39,7 +38,6 @@ public interface SeededExplicitNoiseGenerator<NR extends NoiseResult> 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);

/**
Expand All @@ -52,6 +50,5 @@ public interface SeededExplicitNoiseGenerator<NR extends NoiseResult> 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);
}
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
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.
* Used everywhere where a {@link NoiseSource} has a non-double as a result.
*
* @author Articdive
*/
@NullMarked
public interface ExplicitNoiseSource<NR extends NoiseResult> extends NoiseSource {
/**
* Evaluates noise at a 1D point.
*
* @param x X-Coordinate of the 1D point.
* @return {@link NR} denoting the noise value at the 1D point.
*/
@NotNull
NR evaluateNoiseResult(double x);

/**
Expand All @@ -26,7 +26,6 @@ public interface ExplicitNoiseSource<NR extends NoiseResult> 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);

/**
Expand All @@ -37,7 +36,6 @@ public interface ExplicitNoiseSource<NR extends NoiseResult> 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);

/**
Expand All @@ -49,6 +47,5 @@ public interface ExplicitNoiseSource<NR extends NoiseResult> 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);
}
Original file line number Diff line number Diff line change
@@ -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();
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
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.
* For a more efficient transform for transforming singular coordinate parts see {@link SimpleTransformer}.
*
* @author Articdive
*/
@NullMarked
public interface DetailedTransformer {
/**
* Transforms an x coordinate before noise evaluation.
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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);
}
Original file line number Diff line number Diff line change
@@ -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 {

/**
Expand All @@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -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 {

/**
Expand All @@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -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 {

/**
Expand All @@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -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 {

/**
Expand All @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -41,14 +42,14 @@ public double evaluateNoise(double x, double y, double z, double w) {
*
* @return {@link ConstantNoiseBuilder}.
*/
@NotNull
public static ConstantNoiseBuilder newBuilder() {
return new ConstantNoiseBuilder();
}

/**
* Builder for the {@link ConstantNoiseGenerator}.
*/
@NullMarked
public static final class ConstantNoiseBuilder implements NoiseSourceBuilder {
private double constant = 0;

Expand All @@ -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);
}
Expand Down
Loading

0 comments on commit 61ab6c9

Please sign in to comment.