Class MutableBoolean

java.lang.Object
com.helger.base.numeric.mutable.MutableBoolean
All Implemented Interfaces:
ICloneable<MutableBoolean>, IComparable<MutableBoolean>, IMutableObject<MutableBoolean>, IGenericImplTrait<MutableBoolean>, Comparable<MutableBoolean>

@NotThreadSafe public class MutableBoolean extends Object implements IMutableObject<MutableBoolean>
Object wrapper around a boolean so that it can be passed a final object but is mutable.
Author:
Philip Helger
  • Constructor Details

    • MutableBoolean

      public MutableBoolean(boolean bValue)
      Initialize with a certain value.
      Parameters:
      bValue - The value to be used.
    • MutableBoolean

      public MutableBoolean(@NonNull Boolean aValue)
      Initialize with a certain value.
      Parameters:
      aValue - The value to be used. May not be null.
    • MutableBoolean

      public MutableBoolean(@NonNull MutableBoolean aValue)
      Copy constructor.
      Parameters:
      aValue - The object to copy from. May not be null.
  • Method Details

    • onAfterChange

      @OverrideOnDemand protected void onAfterChange()
      This method is invoked after a value changed.
    • booleanValue

      public boolean booleanValue()
      Returns:
      The current boolean value.
    • getAsBoolean

      public @NonNull Boolean getAsBoolean()
      Returns:
      The current value as a Boolean object. Never null.
    • set

      public @NonNull EChange set(@NonNull Boolean aValue)
      Set a new value.
      Parameters:
      aValue - The new value to set. May not be null.
      Returns:
      EChange.CHANGED if the value was changed.
    • set

      public @NonNull EChange set(@NonNull MutableBoolean aValue)
      Set a new value.
      Parameters:
      aValue - The new value to set. May not be null.
      Returns:
      EChange.CHANGED if the value was changed.
    • set

      public @NonNull EChange set(boolean bValue)
      Set a new value.
      Parameters:
      bValue - The new value to set.
      Returns:
      EChange.CHANGED if the value was changed.
    • getIf

      public <T> @Nullable T getIf(@NonNull Supplier<? extends T> aSupplier)
      If the current value is true, get a value from the supplier; otherwise return null.
      Type Parameters:
      T - The return type.
      Parameters:
      aSupplier - The supplier to use. May not be null.
      Returns:
      The supplied value or null.
    • getIf

      public <T> @Nullable T getIf(@NonNull Supplier<? extends T> aSupplier, @Nullable T aDefault)
      If the current value is true, get a value from the supplier; otherwise return the default value.
      Type Parameters:
      T - The return type.
      Parameters:
      aSupplier - The supplier to use. May not be null.
      aDefault - The default value to return if the current value is false. May be null.
      Returns:
      The supplied value or the default value.
    • compareTo

      public int compareTo(@NonNull MutableBoolean rhs)
      Specified by:
      compareTo in interface Comparable<MutableBoolean>
    • getClone

      public @NonNull MutableBoolean getClone()
      Specified by:
      getClone in interface ICloneable<MutableBoolean>
      Returns:
      A 100% deep-copy of the implementing class.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object