Class LogicBlock

  • All Implemented Interfaces:
    JMetaMetaFunctor, JSONFunctor, Serializable

    public class LogicBlock
    extends Object
    implements JSONFunctor
    This class contains a JFunctor if-then-else block. You supply a JSONObject, this parses it into its correct elements at runtime. You may also use this as a utility to create such blocks by creating the if then else blcks, setting them and invoking the toJSON() method.

    Created by Jeff Gaynor
    on 2/27/18 at 4:33 PM

    See Also:
    Serialized Form
    • Constructor Detail

      • LogicBlock

        public LogicBlock​(JFunctorFactory factory,
                          jIf ifBlock,
                          jThen thenBlock)
        Constructor for case of no else clause.
        Parameters:
        ifBlock -
        thenBlock -
      • LogicBlock

        public LogicBlock​(JFunctorFactory factory,
                          net.sf.json.JSONObject json)
    • Method Detail

      • getConsequent

        public jThen getConsequent()
        The consequent is either the then or else block, depending on the antecedent (the if block). If this has not executed, then null is returned. Also, if there no else and the if clause is false, it will be empty
        Returns:
      • hasConsequent

        public boolean hasConsequent()
      • getElseBlock

        public jElse getElseBlock()
      • getThenBlock

        public jThen getThenBlock()
      • getIfBlock

        public jIf getIfBlock()
      • createIfBlock

        protected jIf createIfBlock()
        A jIf functor is a functor with the agreement that the argument in text may consists of a functor (rather than an array with a single functor). This method will enclose the argument in an array if need be.
        Returns:
      • isIfTrue

        public boolean isIfTrue()
      • isExecuted

        public boolean isExecuted()
      • clearState

        public void clearState()
        This clears every executed functor in the antecedent and any consequents.
      • initialize

        protected void initialize()
      • addResults

        protected void addResults​(Object obj)
      • setIfBlock

        public void setIfBlock​(jIf ifBlock)
      • setThenBlock

        public void setThenBlock​(jThen thenBlock)
      • setElseBlock

        public void setElseBlock​(jElse elseBlock)
      • toJSON

        public net.sf.json.JSONObject toJSON()
        Specified by:
        toJSON in interface JSONFunctor