diff --git a/base/src/main/java/de/staropensource/sosengine/base/utility/Miscellaneous.java b/base/src/main/java/de/staropensource/sosengine/base/utility/Miscellaneous.java
index 65285767..a61a0a80 100644
--- a/base/src/main/java/de/staropensource/sosengine/base/utility/Miscellaneous.java
+++ b/base/src/main/java/de/staropensource/sosengine/base/utility/Miscellaneous.java
@@ -20,8 +20,11 @@
package de.staropensource.sosengine.base.utility;
import de.staropensource.sosengine.base.events.ThrowableCatchEvent;
+import de.staropensource.sosengine.base.exceptions.TristateConversionException;
+import de.staropensource.sosengine.base.types.Tristate;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import org.jetbrains.annotations.Range;
import java.lang.ref.WeakReference;
import java.util.List;
@@ -44,6 +47,41 @@ public final class Miscellaneous {
*/
public Miscellaneous() {}
+ /**
+ * Converts a boolean into an integer.
+ *
+ * @since v1-alpha2
+ */
+ @Range(from = 0, to = 1)
+ public static int getIntegerizedBoolean(boolean bool) {
+ return bool ? 1 : 0;
+ }
+
+ /**
+ * Converts an integer into a {@link Tristate}.
+ *
+ * @return the expected boolean result, except if neither {@code 0} or {@code 1}, in which case {@link Tristate#UNSET} is returned
+ * @since v1-alpha2
+ */
+ public static Tristate getTristatedInteger(@Range(from = 0, to = 1) int integer) {
+ return switch (integer) {
+ case 0 -> Tristate.TRUE;
+ case 1 -> Tristate.FALSE;
+ default -> Tristate.UNSET;
+ };
+ }
+
+ /**
+ * Converts an integer into a {@link Tristate} and then into a boolean.
+ *
+ * @return booleanized integer
+ * @throws TristateConversionException when encountering {@link Tristate#UNSET}.
+ * @since v1-alpha2
+ */
+ public static boolean getBooleanizedInteger(@Range(from = 0, to = 1) int integer) throws TristateConversionException {
+ return Tristate.toBoolean(getTristatedInteger(integer));
+ }
+
/**
* Adds padding zeros to a number.
*
@@ -57,34 +95,6 @@ public final class Miscellaneous {
return String.format("%0" + length + "d", number);
}
- /**
- * Forcefully invokes the garbage collector and blocks execution until finished.
- * If you want to run it in parallel to your program, consider running it in a {@link java.lang.VirtualThread}.
- *
- * @since v1-alpha0
- */
- @SuppressWarnings("UnusedAssignment")
- public static void invokeGarbageCollector() {
- Object object = new Object();
- WeakReference