Package com.prineside.tdi2.utils
Class MultiReasonBool
java.lang.Object
com.prineside.tdi2.utils.MultiReasonBool
- All Implemented Interfaces:
com.esotericsoftware.kryo.KryoSerializable
public final class MultiReasonBool
extends Object
implements com.esotericsoftware.kryo.KryoSerializable
Acts as a regular boolean field / flag which can be affected by multiple sources.
Instead of storing a plain "true" / "false" data, it stores a list of reasons why the field is
true, and acts as a boolean "true" (isTrue() method) if there's at least one reason.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
void
clear()
int
String[]
Use getReasonCount() first If reason count is 0, this method may return null Iteration:String[] reasons = getReasonsBuffer(); for (int i = 0, n = bool.getReasonCount(); i < n; i++) { reasons[i] ...
boolean
boolean
isTrue()
void
read
(com.esotericsoftware.kryo.Kryo kryo, com.esotericsoftware.kryo.io.Input input) boolean
removeReason
(String reason) void
write
(com.esotericsoftware.kryo.Kryo kryo, com.esotericsoftware.kryo.io.Output output)
-
Constructor Details
-
MultiReasonBool
public MultiReasonBool()
-
-
Method Details
-
write
public void write(com.esotericsoftware.kryo.Kryo kryo, com.esotericsoftware.kryo.io.Output output) - Specified by:
write
in interfacecom.esotericsoftware.kryo.KryoSerializable
-
read
public void read(com.esotericsoftware.kryo.Kryo kryo, com.esotericsoftware.kryo.io.Input input) - Specified by:
read
in interfacecom.esotericsoftware.kryo.KryoSerializable
-
addReason
- Returns:
- true if added
-
hasReason
-
removeReason
- Returns:
- true if has been removed
-
getReasonCount
public int getReasonCount() -
isTrue
public boolean isTrue() -
clear
public void clear() -
getReasonsBuffer
Use getReasonCount() first If reason count is 0, this method may return null Iteration:String[] reasons = getReasonsBuffer(); for (int i = 0, n = bool.getReasonCount(); i < n; i++) { reasons[i] ... }
-