forked from StarOpenSource/Engine
Mark all arrays as @NotNull
This commit is contained in:
parent
02aa744098
commit
dd4ebcd88a
17 changed files with 92 additions and 22 deletions
|
@ -36,7 +36,7 @@ public class IncompatibleTypeException extends RuntimeException {
|
||||||
* @param requiredClassType class type received by the method
|
* @param requiredClassType class type received by the method
|
||||||
* @param compatibleTypes class types the method is compatible with
|
* @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());
|
super("The method ReflectionClass#" + methodName + " only applies to type(s) " + ListFormatter.formatArray(compatibleTypes) + ", not " + requiredClassType.name());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ public final class EventListenerMethod extends EventListenerCode {
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
@Override
|
@Override
|
||||||
public void run(Object[] arguments) throws Exception {
|
public void run(@Nullable Object @NotNull [] arguments) throws Exception {
|
||||||
method.invoke(arguments);
|
method.invoke(arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -152,7 +152,7 @@ public record ReflectionClass(Class<?> clazz) {
|
||||||
* @return array of all annotations
|
* @return array of all annotations
|
||||||
* @since v1-alpha2
|
* @since v1-alpha2
|
||||||
*/
|
*/
|
||||||
public Annotation[] getAnnotations() {
|
public Annotation @NotNull [] getAnnotations() {
|
||||||
return clazz.getAnnotations();
|
return clazz.getAnnotations();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -299,7 +299,7 @@ public final class ReflectionField {
|
||||||
* @return array of all annotations
|
* @return array of all annotations
|
||||||
* @since v1-alpha2
|
* @since v1-alpha2
|
||||||
*/
|
*/
|
||||||
public Annotation[] getAnnotations() {
|
public Annotation @NotNull [] getAnnotations() {
|
||||||
return field.getAnnotations();
|
return field.getAnnotations();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -303,7 +303,7 @@ public final class ReflectionMethod {
|
||||||
* @return array of all annotations
|
* @return array of all annotations
|
||||||
* @since v1-alpha2
|
* @since v1-alpha2
|
||||||
*/
|
*/
|
||||||
public Annotation[] getAnnotations() {
|
public Annotation @NotNull [] getAnnotations() {
|
||||||
return method.getAnnotations();
|
return method.getAnnotations();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ package de.staropensource.engine.base.type;
|
||||||
import de.staropensource.engine.base.EngineInternals;
|
import de.staropensource.engine.base.EngineInternals;
|
||||||
import de.staropensource.engine.base.implementable.Event;
|
import de.staropensource.engine.base.implementable.Event;
|
||||||
import de.staropensource.engine.base.implementable.ShutdownHandler;
|
import de.staropensource.engine.base.implementable.ShutdownHandler;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specifies multiple areas of internal engine access.
|
* Specifies multiple areas of internal engine access.
|
||||||
|
@ -110,7 +111,7 @@ public enum InternalAccessArea {
|
||||||
* @return array containing all read-only areas
|
* @return array containing all read-only areas
|
||||||
* @since v1-alpha4
|
* @since v1-alpha4
|
||||||
*/
|
*/
|
||||||
public static InternalAccessArea[] valuesReadOnly() {
|
public static @NotNull InternalAccessArea @NotNull [] valuesReadOnly() {
|
||||||
return new InternalAccessArea[]{
|
return new InternalAccessArea[]{
|
||||||
SHUTDOWN_HANDLER_GET,
|
SHUTDOWN_HANDLER_GET,
|
||||||
};
|
};
|
||||||
|
@ -122,7 +123,7 @@ public enum InternalAccessArea {
|
||||||
* @return array containing all essential read-only areas
|
* @return array containing all essential read-only areas
|
||||||
* @since v1-alpha5
|
* @since v1-alpha5
|
||||||
*/
|
*/
|
||||||
public static InternalAccessArea[] valuesEssentialReadOnly() {
|
public static @NotNull InternalAccessArea @NotNull [] valuesEssentialReadOnly() {
|
||||||
return new InternalAccessArea[]{
|
return new InternalAccessArea[]{
|
||||||
REFLECTIVE_CLASSPATH_SCANNING_GET,
|
REFLECTIVE_CLASSPATH_SCANNING_GET,
|
||||||
};
|
};
|
||||||
|
@ -134,7 +135,7 @@ public enum InternalAccessArea {
|
||||||
* @return array containing all write-only areas
|
* @return array containing all write-only areas
|
||||||
* @since v1-alpha4
|
* @since v1-alpha4
|
||||||
*/
|
*/
|
||||||
public static InternalAccessArea[] valuesWriteOnly() {
|
public static @NotNull InternalAccessArea @NotNull [] valuesWriteOnly() {
|
||||||
return new InternalAccessArea[]{
|
return new InternalAccessArea[]{
|
||||||
SAFETY_SHUTDOWN_HOOK_UPDATE,
|
SAFETY_SHUTDOWN_HOOK_UPDATE,
|
||||||
SHUTDOWN_HANDLER_UPDATE,
|
SHUTDOWN_HANDLER_UPDATE,
|
||||||
|
|
|
@ -33,7 +33,7 @@ import org.jetbrains.annotations.NotNull;
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@SuppressWarnings({ "JavadocDeclaration" })
|
@SuppressWarnings({ "JavadocDeclaration" })
|
||||||
public class Vec2d {
|
public final class Vec2d {
|
||||||
/**
|
/**
|
||||||
* The X axis value.
|
* The X axis value.
|
||||||
*
|
*
|
||||||
|
|
|
@ -33,7 +33,7 @@ import org.jetbrains.annotations.NotNull;
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@SuppressWarnings({ "JavadocDeclaration" })
|
@SuppressWarnings({ "JavadocDeclaration" })
|
||||||
public class Vec2f {
|
public final class Vec2f {
|
||||||
/**
|
/**
|
||||||
* The X axis value.
|
* The X axis value.
|
||||||
*
|
*
|
||||||
|
|
|
@ -33,7 +33,7 @@ import org.jetbrains.annotations.NotNull;
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@SuppressWarnings({ "JavadocDeclaration" })
|
@SuppressWarnings({ "JavadocDeclaration" })
|
||||||
public class Vec2i implements Cloneable {
|
public final class Vec2i implements Cloneable {
|
||||||
/**
|
/**
|
||||||
* The X axis value.
|
* The X axis value.
|
||||||
*
|
*
|
||||||
|
|
|
@ -33,7 +33,7 @@ import org.jetbrains.annotations.NotNull;
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@SuppressWarnings({ "JavadocDeclaration" })
|
@SuppressWarnings({ "JavadocDeclaration" })
|
||||||
public class Vec3d {
|
public final class Vec3d {
|
||||||
/**
|
/**
|
||||||
* The X axis value.
|
* The X axis value.
|
||||||
*
|
*
|
||||||
|
@ -121,6 +121,6 @@ public class Vec3d {
|
||||||
return (EngineConfiguration.getInstance().isHideFullTypePath()
|
return (EngineConfiguration.getInstance().isHideFullTypePath()
|
||||||
? getClass().getName().replace(getClass().getPackage() + ".", "")
|
? getClass().getName().replace(getClass().getPackage() + ".", "")
|
||||||
: getClass().getName())
|
: getClass().getName())
|
||||||
+ "(x=" + x + " y=" + y + ")";
|
+ "(x=" + x + " y=" + y + " z=" + z + ")";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ import org.jetbrains.annotations.NotNull;
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@SuppressWarnings({ "JavadocDeclaration" })
|
@SuppressWarnings({ "JavadocDeclaration" })
|
||||||
public class Vec3f {
|
public final class Vec3f {
|
||||||
/**
|
/**
|
||||||
* The X axis value.
|
* The X axis value.
|
||||||
*
|
*
|
||||||
|
@ -121,6 +121,6 @@ public class Vec3f {
|
||||||
return (EngineConfiguration.getInstance().isHideFullTypePath()
|
return (EngineConfiguration.getInstance().isHideFullTypePath()
|
||||||
? getClass().getName().replace(getClass().getPackage() + ".", "")
|
? getClass().getName().replace(getClass().getPackage() + ".", "")
|
||||||
: getClass().getName())
|
: getClass().getName())
|
||||||
+ "(x=" + x + " y=" + y + ")";
|
+ "(x=" + x + " y=" + y + " z=" + z + ")";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ import org.jetbrains.annotations.NotNull;
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@SuppressWarnings({ "JavadocDeclaration" })
|
@SuppressWarnings({ "JavadocDeclaration" })
|
||||||
public class Vec3i {
|
public final class Vec3i {
|
||||||
/**
|
/**
|
||||||
* The X axis value.
|
* The X axis value.
|
||||||
*
|
*
|
||||||
|
@ -121,6 +121,6 @@ public class Vec3i {
|
||||||
return (EngineConfiguration.getInstance().isHideFullTypePath()
|
return (EngineConfiguration.getInstance().isHideFullTypePath()
|
||||||
? getClass().getName().replace(getClass().getPackage() + ".", "")
|
? getClass().getName().replace(getClass().getPackage() + ".", "")
|
||||||
: getClass().getName())
|
: getClass().getName())
|
||||||
+ "(x=" + x + " y=" + y + ")";
|
+ "(x=" + x + " y=" + y + " z=" + z + ")";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,7 +100,7 @@ public final class DependencyResolver {
|
||||||
* @return itself
|
* @return itself
|
||||||
* @since v1-alpha1
|
* @since v1-alpha1
|
||||||
*/
|
*/
|
||||||
public @NotNull DependencyResolver addVectors(@NotNull DependencyVector[] vectors) {
|
public @NotNull DependencyResolver addVectors(@NotNull DependencyVector @NotNull [] vectors) {
|
||||||
return addVectors(Arrays.stream(vectors).toList());
|
return addVectors(Arrays.stream(vectors).toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ public final class ListFormatter {
|
||||||
* @return formatted string
|
* @return formatted string
|
||||||
* @since v1-alpha4
|
* @since v1-alpha4
|
||||||
*/
|
*/
|
||||||
public static @NotNull String formatArray(@NotNull Object[] array) {
|
public static @NotNull String formatArray(@NotNull Object @NotNull [] array) {
|
||||||
StringBuilder output = new StringBuilder();
|
StringBuilder output = new StringBuilder();
|
||||||
|
|
||||||
for (int index = 0; index < array.length; index++) {
|
for (int index = 0; index < array.length; index++) {
|
||||||
|
|
|
@ -52,6 +52,75 @@ public final class Math {
|
||||||
return String.format("%0" + length + "d", number);
|
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.
|
* Returns the mean of a collection of numbers.
|
||||||
*
|
*
|
||||||
|
|
|
@ -119,7 +119,7 @@ public final class Miscellaneous {
|
||||||
* @return separator to use or {@code null}
|
* @return separator to use or {@code null}
|
||||||
* @since v1-alpha1
|
* @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)
|
if (string.isBlank() || separators.length == 0 || requiredOccurrences == 0)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
@ -225,7 +225,7 @@ public final class Miscellaneous {
|
||||||
* @return converted stacktrace string
|
* @return converted stacktrace string
|
||||||
* @since v1-alpha4
|
* @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();
|
StringBuilder output = new StringBuilder();
|
||||||
|
|
||||||
for (StackTraceElement element : stacktrace) {
|
for (StackTraceElement element : stacktrace) {
|
||||||
|
|
|
@ -101,7 +101,7 @@ public final class Main {
|
||||||
* @param args program's command line arguments
|
* @param args program's command line arguments
|
||||||
* @since v1-alpha0
|
* @since v1-alpha0
|
||||||
*/
|
*/
|
||||||
public static void main(String[] args) {
|
public static void main(String @NotNull [] args) {
|
||||||
getInstance().run();
|
getInstance().run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue