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 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 interface com.esotericsoftware.kryo.KryoSerializable
    • read

      public void read(com.esotericsoftware.kryo.Kryo kryo, com.esotericsoftware.kryo.io.Input input)
      Specified by:
      read in interface com.esotericsoftware.kryo.KryoSerializable
    • addReason

      public boolean addReason(String reason)
      Returns:
      true if added
    • hasReason

      public boolean hasReason(String reason)
    • removeReason

      public boolean removeReason(String reason)
      Returns:
      true if has been removed
    • getReasonCount

      public int getReasonCount()
    • isTrue

      public boolean isTrue()
    • clear

      public void clear()
    • getReasonsBuffer

      public String[] 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] ... }