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;
import de.staropensource.sosengine.base.exception.TristateConversionException;
import org.jetbrains.annotations.NotNull;
/**
* Just a {@link Boolean}, but it can be {@link #UNSET}.
@ -48,6 +49,17 @@ public enum Tristate {
*/
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}.
* Make sure to check for {@link #UNSET} first.