From 5766072fd72afd3b5f65a0b1bdc859ef478ff436 Mon Sep 17 00:00:00 2001 From: JeremyStarTM Date: Sat, 7 Sep 2024 16:52:17 +0200 Subject: [PATCH] Make Tristate#toBoolean no longer static --- .../de/staropensource/sosengine/base/type/Tristate.java | 8 +++----- .../sosengine/base/utility/Miscellaneous.java | 2 +- .../windowing/glfw/implementable/GlfwWindow.java | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/base/src/main/java/de/staropensource/sosengine/base/type/Tristate.java b/base/src/main/java/de/staropensource/sosengine/base/type/Tristate.java index 916a676..bb936dd 100644 --- a/base/src/main/java/de/staropensource/sosengine/base/type/Tristate.java +++ b/base/src/main/java/de/staropensource/sosengine/base/type/Tristate.java @@ -20,7 +20,6 @@ package de.staropensource.sosengine.base.type; import de.staropensource.sosengine.base.exception.TristateConversionException; -import org.jetbrains.annotations.NotNull; /** * Just a {@link Boolean}, but it can be {@link #UNSET}. @@ -50,16 +49,15 @@ public enum Tristate { FALSE; /** - * Converts a {@link Tristate} into a {@link Boolean}. + * Converts the {@link Tristate} into a {@link Boolean}. * Make sure to check for {@link #UNSET} first. * - * @param tristate {@link Tristate} to convert * @return booleanized {@link Tristate} * @throws TristateConversionException when encountering {@link #UNSET} * @since v1-alpha2 */ - public static boolean toBoolean(@NotNull Tristate tristate) { - return switch (tristate) { + public boolean toBoolean() { + return switch (this) { case UNSET -> throw new TristateConversionException(); case TRUE -> true; case FALSE -> false; 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 0b8719b..3805624 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 @@ -80,7 +80,7 @@ public final class Miscellaneous { * @since v1-alpha2 */ public static boolean getBooleanizedInteger(@Range(from = 0, to = 1) int integer) throws TristateConversionException { - return Tristate.toBoolean(getTristatedInteger(integer)); + return getTristatedInteger(integer).toBoolean(); } /** diff --git a/windowing/glfw/src/main/java/de/staropensource/sosengine/windowing/glfw/implementable/GlfwWindow.java b/windowing/glfw/src/main/java/de/staropensource/sosengine/windowing/glfw/implementable/GlfwWindow.java index 498607a..eff119c 100644 --- a/windowing/glfw/src/main/java/de/staropensource/sosengine/windowing/glfw/implementable/GlfwWindow.java +++ b/windowing/glfw/src/main/java/de/staropensource/sosengine/windowing/glfw/implementable/GlfwWindow.java @@ -328,7 +328,7 @@ public class GlfwWindow extends Window { if (isTerminated()) return false; - return Tristate.toBoolean(Miscellaneous.getTristatedInteger(glfwGetWindowAttrib(identifierLong, GLFW_FOCUSED))); + return Miscellaneous.getTristatedInteger(glfwGetWindowAttrib(identifierLong, GLFW_FOCUSED)).toBoolean(); } /** {@inheritDoc} */