Add static Tristate#toTristate method
This commit is contained in:
parent
45f02bdd5a
commit
a9cfc8c810
1 changed files with 12 additions and 0 deletions
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue