From d6e66dc22d0d97687dc9ebe9771d1080d2e3ed3f Mon Sep 17 00:00:00 2001 From: asofold Date: Wed, 4 Jun 2014 22:04:17 +0200 Subject: [PATCH] Simplify and extend AlmostBoolean. --- .../nocheatplus/compat/AlmostBoolean.java | 39 +++++++++++++------ 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/compat/AlmostBoolean.java b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/compat/AlmostBoolean.java index 539f3d1b..54a58efe 100644 --- a/NCPCore/src/main/java/fr/neatmonster/nocheatplus/compat/AlmostBoolean.java +++ b/NCPCore/src/main/java/fr/neatmonster/nocheatplus/compat/AlmostBoolean.java @@ -1,21 +1,38 @@ package fr.neatmonster.nocheatplus.compat; +/** + * Some tri-state with booleans in mind. + * @author mc_dev + * + */ public enum AlmostBoolean{ - YES(true), - NO(false), - MAYBE(false); - + YES, + NO, + MAYBE; + + /** + * "Match" a boolean. + * @param value + * @return + */ public static final AlmostBoolean match(final boolean value) { return value ? YES : NO; } - - private final boolean decision; - - private AlmostBoolean(final boolean decision){ - this.decision = decision; - } + /** + * Pessimistic interpretation: true iff YES. + * @return + */ public boolean decide(){ - return decision; + return this == YES; } + + /** + * Optimistic interpretation: true iff not NO. + * @return + */ + public boolean decideOptimistically() { + return this != NO; + } + }