forked from StarOpenSource/Engine
Make Tristate#toBoolean no longer static
This commit is contained in:
parent
b49ff9a569
commit
5766072fd7
3 changed files with 5 additions and 7 deletions
|
@ -20,7 +20,6 @@
|
||||||
package de.staropensource.sosengine.base.type;
|
package de.staropensource.sosengine.base.type;
|
||||||
|
|
||||||
import de.staropensource.sosengine.base.exception.TristateConversionException;
|
import de.staropensource.sosengine.base.exception.TristateConversionException;
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Just a {@link Boolean}, but it can be {@link #UNSET}.
|
* Just a {@link Boolean}, but it can be {@link #UNSET}.
|
||||||
|
@ -50,16 +49,15 @@ public enum Tristate {
|
||||||
FALSE;
|
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.
|
* Make sure to check for {@link #UNSET} first.
|
||||||
*
|
*
|
||||||
* @param tristate {@link Tristate} to convert
|
|
||||||
* @return booleanized {@link Tristate}
|
* @return booleanized {@link Tristate}
|
||||||
* @throws TristateConversionException when encountering {@link #UNSET}
|
* @throws TristateConversionException when encountering {@link #UNSET}
|
||||||
* @since v1-alpha2
|
* @since v1-alpha2
|
||||||
*/
|
*/
|
||||||
public static boolean toBoolean(@NotNull Tristate tristate) {
|
public boolean toBoolean() {
|
||||||
return switch (tristate) {
|
return switch (this) {
|
||||||
case UNSET -> throw new TristateConversionException();
|
case UNSET -> throw new TristateConversionException();
|
||||||
case TRUE -> true;
|
case TRUE -> true;
|
||||||
case FALSE -> false;
|
case FALSE -> false;
|
||||||
|
|
|
@ -80,7 +80,7 @@ public final class Miscellaneous {
|
||||||
* @since v1-alpha2
|
* @since v1-alpha2
|
||||||
*/
|
*/
|
||||||
public static boolean getBooleanizedInteger(@Range(from = 0, to = 1) int integer) throws TristateConversionException {
|
public static boolean getBooleanizedInteger(@Range(from = 0, to = 1) int integer) throws TristateConversionException {
|
||||||
return Tristate.toBoolean(getTristatedInteger(integer));
|
return getTristatedInteger(integer).toBoolean();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -328,7 +328,7 @@ public class GlfwWindow extends Window {
|
||||||
if (isTerminated())
|
if (isTerminated())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return Tristate.toBoolean(Miscellaneous.getTristatedInteger(glfwGetWindowAttrib(identifierLong, GLFW_FOCUSED)));
|
return Miscellaneous.getTristatedInteger(glfwGetWindowAttrib(identifierLong, GLFW_FOCUSED)).toBoolean();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
|
|
Loading…
Reference in a new issue