Mark all arrays as @NotNull

This commit is contained in:
JeremyStar™ 2024-09-28 16:59:45 +02:00
parent 02aa744098
commit dd4ebcd88a
Signed by: JeremyStarTM
GPG key ID: E366BAEF67E4704D
17 changed files with 92 additions and 22 deletions

View file

@ -36,7 +36,7 @@ public class IncompatibleTypeException extends RuntimeException {
* @param requiredClassType class type received by the method
* @param compatibleTypes class types the method is compatible with
*/
public IncompatibleTypeException(@NotNull String methodName, @NotNull ClassType requiredClassType, @NotNull ClassType[] compatibleTypes) {
public IncompatibleTypeException(@NotNull String methodName, @NotNull ClassType requiredClassType, @NotNull ClassType @NotNull [] compatibleTypes) {
super("The method ReflectionClass#" + methodName + " only applies to type(s) " + ListFormatter.formatArray(compatibleTypes) + ", not " + requiredClassType.name());
}

View file

@ -53,7 +53,7 @@ public final class EventListenerMethod extends EventListenerCode {
/** {@inheritDoc} */
@Override
public void run(Object[] arguments) throws Exception {
public void run(@Nullable Object @NotNull [] arguments) throws Exception {
method.invoke(arguments);
}

View file

@ -152,7 +152,7 @@ public record ReflectionClass(Class<?> clazz) {
* @return array of all annotations
* @since v1-alpha2
*/
public Annotation[] getAnnotations() {
public Annotation @NotNull [] getAnnotations() {
return clazz.getAnnotations();
}

View file

@ -299,7 +299,7 @@ public final class ReflectionField {
* @return array of all annotations
* @since v1-alpha2
*/
public Annotation[] getAnnotations() {
public Annotation @NotNull [] getAnnotations() {
return field.getAnnotations();
}

View file

@ -303,7 +303,7 @@ public final class ReflectionMethod {
* @return array of all annotations
* @since v1-alpha2
*/
public Annotation[] getAnnotations() {
public Annotation @NotNull [] getAnnotations() {
return method.getAnnotations();
}

View file

@ -22,6 +22,7 @@ package de.staropensource.engine.base.type;
import de.staropensource.engine.base.EngineInternals;
import de.staropensource.engine.base.implementable.Event;
import de.staropensource.engine.base.implementable.ShutdownHandler;
import org.jetbrains.annotations.NotNull;
/**
* Specifies multiple areas of internal engine access.
@ -110,7 +111,7 @@ public enum InternalAccessArea {
* @return array containing all read-only areas
* @since v1-alpha4
*/
public static InternalAccessArea[] valuesReadOnly() {
public static @NotNull InternalAccessArea @NotNull [] valuesReadOnly() {
return new InternalAccessArea[]{
SHUTDOWN_HANDLER_GET,
};
@ -122,7 +123,7 @@ public enum InternalAccessArea {
* @return array containing all essential read-only areas
* @since v1-alpha5
*/
public static InternalAccessArea[] valuesEssentialReadOnly() {
public static @NotNull InternalAccessArea @NotNull [] valuesEssentialReadOnly() {
return new InternalAccessArea[]{
REFLECTIVE_CLASSPATH_SCANNING_GET,
};
@ -134,7 +135,7 @@ public enum InternalAccessArea {
* @return array containing all write-only areas
* @since v1-alpha4
*/
public static InternalAccessArea[] valuesWriteOnly() {
public static @NotNull InternalAccessArea @NotNull [] valuesWriteOnly() {
return new InternalAccessArea[]{
SAFETY_SHUTDOWN_HOOK_UPDATE,
SHUTDOWN_HANDLER_UPDATE,

View file

@ -33,7 +33,7 @@ import org.jetbrains.annotations.NotNull;
@Getter
@Setter
@SuppressWarnings({ "JavadocDeclaration" })
public class Vec2d {
public final class Vec2d {
/**
* The X axis value.
*

View file

@ -33,7 +33,7 @@ import org.jetbrains.annotations.NotNull;
@Getter
@Setter
@SuppressWarnings({ "JavadocDeclaration" })
public class Vec2f {
public final class Vec2f {
/**
* The X axis value.
*

View file

@ -33,7 +33,7 @@ import org.jetbrains.annotations.NotNull;
@Getter
@Setter
@SuppressWarnings({ "JavadocDeclaration" })
public class Vec2i implements Cloneable {
public final class Vec2i implements Cloneable {
/**
* The X axis value.
*

View file

@ -33,7 +33,7 @@ import org.jetbrains.annotations.NotNull;
@Getter
@Setter
@SuppressWarnings({ "JavadocDeclaration" })
public class Vec3d {
public final class Vec3d {
/**
* The X axis value.
*
@ -121,6 +121,6 @@ public class Vec3d {
return (EngineConfiguration.getInstance().isHideFullTypePath()
? getClass().getName().replace(getClass().getPackage() + ".", "")
: getClass().getName())
+ "(x=" + x + " y=" + y + ")";
+ "(x=" + x + " y=" + y + " z=" + z + ")";
}
}

View file

@ -33,7 +33,7 @@ import org.jetbrains.annotations.NotNull;
@Getter
@Setter
@SuppressWarnings({ "JavadocDeclaration" })
public class Vec3f {
public final class Vec3f {
/**
* The X axis value.
*
@ -121,6 +121,6 @@ public class Vec3f {
return (EngineConfiguration.getInstance().isHideFullTypePath()
? getClass().getName().replace(getClass().getPackage() + ".", "")
: getClass().getName())
+ "(x=" + x + " y=" + y + ")";
+ "(x=" + x + " y=" + y + " z=" + z + ")";
}
}

View file

@ -33,7 +33,7 @@ import org.jetbrains.annotations.NotNull;
@Getter
@Setter
@SuppressWarnings({ "JavadocDeclaration" })
public class Vec3i {
public final class Vec3i {
/**
* The X axis value.
*
@ -121,6 +121,6 @@ public class Vec3i {
return (EngineConfiguration.getInstance().isHideFullTypePath()
? getClass().getName().replace(getClass().getPackage() + ".", "")
: getClass().getName())
+ "(x=" + x + " y=" + y + ")";
+ "(x=" + x + " y=" + y + " z=" + z + ")";
}
}

View file

@ -100,7 +100,7 @@ public final class DependencyResolver {
* @return itself
* @since v1-alpha1
*/
public @NotNull DependencyResolver addVectors(@NotNull DependencyVector[] vectors) {
public @NotNull DependencyResolver addVectors(@NotNull DependencyVector @NotNull [] vectors) {
return addVectors(Arrays.stream(vectors).toList());
}

View file

@ -45,7 +45,7 @@ public final class ListFormatter {
* @return formatted string
* @since v1-alpha4
*/
public static @NotNull String formatArray(@NotNull Object[] array) {
public static @NotNull String formatArray(@NotNull Object @NotNull [] array) {
StringBuilder output = new StringBuilder();
for (int index = 0; index < array.length; index++) {

View file

@ -52,6 +52,75 @@ public final class Math {
return String.format("%0" + length + "d", number);
}
/**
* Ensures the integer is inside the
* specified bounds. If not, the
* integer will be corrected.
*
* @param min minimum value
* @param max maximum value
* @param value value
* @throws IndexOutOfBoundsException when the minimum value is bigger than the maximum value
* @since v1-alpha6
*/
public static int boundNumber(int min, int max, int value) throws IndexOutOfBoundsException {
if (min > max)
throw new IndexOutOfBoundsException();
if (value < min)
value = min;
else if (value > max)
value = max;
return value;
}
/**
* Ensures the float is inside the
* specified bounds. If not, the
* float will be corrected.
*
* @param min minimum value
* @param max maximum value
* @param value value
* @throws IndexOutOfBoundsException when the minimum value is bigger than the maximum value
* @since v1-alpha6
*/
public static float boundNumber(float min, float max, float value) throws IndexOutOfBoundsException {
if (min > max)
throw new IndexOutOfBoundsException();
if (value < min)
value = min;
else if (value > max)
value = max;
return value;
}
/**
* Ensures the double is inside the
* specified bounds. If not, the
* double will be corrected.
*
* @param min minimum value
* @param max maximum value
* @param value value
* @throws IndexOutOfBoundsException when the minimum value is bigger than the maximum value
* @since v1-alpha6
*/
public static double boundNumber(double min, double max, double value) throws IndexOutOfBoundsException {
if (min > max)
throw new IndexOutOfBoundsException();
if (value < min)
value = min;
else if (value > max)
value = max;
return value;
}
/**
* Returns the mean of a collection of numbers.
*

View file

@ -119,7 +119,7 @@ public final class Miscellaneous {
* @return separator to use or {@code null}
* @since v1-alpha1
*/
public static @Nullable String getSeparator(@NotNull String string, String[] separators, int requiredOccurrences) {
public static @Nullable String getSeparator(@NotNull String string, @NotNull String @NotNull [] separators, int requiredOccurrences) {
if (string.isBlank() || separators.length == 0 || requiredOccurrences == 0)
return null;
@ -225,7 +225,7 @@ public final class Miscellaneous {
* @return converted stacktrace string
* @since v1-alpha4
*/
public static @NotNull String getStackTraceAsString(@NotNull StackTraceElement[] stacktrace, boolean indent) {
public static @NotNull String getStackTraceAsString(@NotNull StackTraceElement @NotNull [] stacktrace, boolean indent) {
StringBuilder output = new StringBuilder();
for (StackTraceElement element : stacktrace) {

View file

@ -101,7 +101,7 @@ public final class Main {
* @param args program's command line arguments
* @since v1-alpha0
*/
public static void main(String[] args) {
public static void main(String @NotNull [] args) {
getInstance().run();
}