mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-11-07 03:02:11 +01:00
Simplify and extend AlmostBoolean.
This commit is contained in:
parent
1ada725476
commit
d6e66dc22d
@ -1,21 +1,38 @@
|
|||||||
package fr.neatmonster.nocheatplus.compat;
|
package fr.neatmonster.nocheatplus.compat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Some tri-state with booleans in mind.
|
||||||
|
* @author mc_dev
|
||||||
|
*
|
||||||
|
*/
|
||||||
public enum AlmostBoolean{
|
public enum AlmostBoolean{
|
||||||
YES(true),
|
YES,
|
||||||
NO(false),
|
NO,
|
||||||
MAYBE(false);
|
MAYBE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* "Match" a boolean.
|
||||||
|
* @param value
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public static final AlmostBoolean match(final boolean value) {
|
public static final AlmostBoolean match(final boolean value) {
|
||||||
return value ? YES : NO;
|
return value ? YES : NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final boolean decision;
|
/**
|
||||||
|
* Pessimistic interpretation: true iff YES.
|
||||||
private AlmostBoolean(final boolean decision){
|
* @return
|
||||||
this.decision = decision;
|
*/
|
||||||
}
|
|
||||||
|
|
||||||
public boolean decide(){
|
public boolean decide(){
|
||||||
return decision;
|
return this == YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Optimistic interpretation: true iff not NO.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean decideOptimistically() {
|
||||||
|
return this != NO;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user