Tristate extensions
liach opened this issue ยท 1 comments
The tristate enum is a good one. To improve its usability, I propose a few changes to its usage:
Addition of methods:
boolean getOr(boolean fallback)
. This will return the corresponding boolean value if the enum value is notDEFAULT
, andfallback
for default. We cannot just assumeDEFAULT
is false.boolean getOr(BooleanSupplier supplier)
. Similar toget(boolean)
but can be used to save a few potentially expensive calls, likepermApi.getPermission(player, permKey).getOr(player::isGeneralPermissionTarget)
.@Nullable Boolean asNullableBoolean()
: simple enough, returns a nullable boolean representationstatic Tristate fromNullableBoolean(@Nullable Boolean value)
similar to above
So more of an OptionalBoolean, like this?