Class AbstractLogical

java.lang.Object
xyz.ronella.trivial.command.logic.AbstractLogical
All Implemented Interfaces:
BiConsumer<Sink,Sink>, Consumer<Sink>, ILogical
Direct Known Subclasses:
LogicAND, LogicOR

public abstract class AbstractLogical extends Object implements ILogical
A partial implementation of the logic command.
Since:
2.0.0
  • Field Details

    • conditions

      protected List<BooleanSupplier> conditions
      A list of BooleanSupplier.
    • defaultTruthLogic

      protected Sink defaultTruthLogic
      The default truth logic
    • defaultFalseLogic

      protected Sink defaultFalseLogic
      The default false logic.
  • Constructor Details

    • AbstractLogical

      public AbstractLogical(List<BooleanSupplier> conditions, Sink defaultTruthLogic, Sink defaultFalseLogic)
      Creates an instance of AbstractLogical.
      Parameters:
      conditions - A list of BooleanSupplier.
      defaultTruthLogic - The default truth logic.
      defaultFalseLogic - The default false logic.
    • AbstractLogical

      public AbstractLogical(List<BooleanSupplier> conditions, Sink defaultTruthLogic)
      Creates an instance of AbstractLogical.
      Parameters:
      conditions - A list of BooleanSupplier.
      defaultTruthLogic - The default truth logic.
    • AbstractLogical

      public AbstractLogical(List<BooleanSupplier> conditions)
      Creates an instance of AbstractLogical.
      Parameters:
      conditions - A list of BooleanSupplier.
    • AbstractLogical

      public AbstractLogical(Sink defaultTruthLogic, Sink defaultFalseLogic, BooleanSupplier... conditions)
      Creates an instance of AbstractLogical.
      Parameters:
      defaultTruthLogic - The default truth logic.
      defaultFalseLogic - The default false logic.
      conditions - An array of BooleanSupplier.
    • AbstractLogical

      public AbstractLogical(Sink defaultTruthLogic, BooleanSupplier... conditions)
      Creates an instance of AbstractLogical.
      Parameters:
      defaultTruthLogic - The default truth logic.
      conditions - An array of BooleanSupplier.
    • AbstractLogical

      public AbstractLogical(BooleanSupplier... conditions)
      Creates an instance of AbstractLogical.
      Parameters:
      conditions - An array of BooleanSupplier.
  • Method Details

    • accept

      public void accept(Sink truthLogic)
      The default implementation is just passing to the BiConsumer implementation.
      Specified by:
      accept in interface Consumer<Sink>
      Parameters:
      truthLogic - Overrides the defaultTruthLogic if not null.
    • getTruthCondition

      public abstract boolean getTruthCondition(List<BooleanSupplier> conditions)
      Determines the truth condition.
      Parameters:
      conditions - The list of conditions
      Returns:
      True when the truthLogic must be called.
    • accept

      public void accept(Sink truthLogic, Sink falseLogic)
      Calculates if the truthLogic or falseLogic must be executed.
      Specified by:
      accept in interface BiConsumer<Sink,Sink>
      Parameters:
      truthLogic - The logic to be executed when all the conditions are true.
      falseLogic - The logic to be executed when at least one condition is false.