Add static Tristate#toTristate method

This commit is contained in:
JeremyStar™ 2024-09-21 17:08:59 +02:00
parent 45f02bdd5a
commit a9cfc8c810
Signed by: JeremyStarTM
GPG key ID: E366BAEF67E4704D

View file

@ -20,6 +20,7 @@
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}.
@ -48,6 +49,17 @@ public enum Tristate {
*/ */
FALSE; FALSE;
/**
* Converts the {@link Boolean} into a {@link Tristate}.
*
* @return tristated boolean
* @since v1-alpha5
*/
public static @NotNull Tristate toTristate(boolean bool) {
if (bool) return Tristate.TRUE;
else return Tristate.FALSE;
}
/** /**
* Converts the {@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.