Class FWRuleSet

java.lang.Object
net.simplace.pipe.control.FWRuleSet

public class FWRuleSet extends Object
Ordered rules of the pipeline control, used by RuleProcessor and RuleFunctionality. Each rule is a JEXL expression or script with the same syntax as the rules of a solution (${a.b} is the value of the parameter a.b):
<rule target="sim_work.multiple">${sim_work.simulationcount} gt 1</rule>
<rule target="sim_work.resultpage">
  if (${sim_work.multiple}) { 'sim_work.form.result_simulation'; } else { 'sim_work.form.result_variable'; }
</rule>
The rule text is taken as it is (placeholders are not replaced before). The rules are evaluated in their order; the result of a rule is set as parameter target, so later rules see the results of earlier ones. Results of reserved targets (e.g. nextFunction of a switch point) are only returned. A rule that cannot be evaluated or gives null is logged and sets nothing.
Author:
Andreas Enders
  • Field Details

  • Constructor Details

    • FWRuleSet

      public FWRuleSet(org.jdom2.Element aElement)
      Reads the rule children of an element. Rules without target or text are logged and skipped.
      Parameters:
      aElement - the element containing the rules, may be null
  • Method Details

    • isEmpty

      public boolean isEmpty()
      Returns:
      true if there are no rules
    • evaluate

      public Map<String,Object> evaluate(net.simplace.core.FWObservable aObservable, Collection<String> aReservedTargets)
      Evaluates the rules in their order, see class description.
      Parameters:
      aObservable - the parameters; the results of all not reserved targets are set here (without notification)
      aReservedTargets - targets that are only returned, not set as parameter; may be empty
      Returns:
      the results of all rules that gave a value, by target, in order of evaluation
    • evaluate

      public Map<String,Object> evaluate(net.simplace.core.FWObservable aObservable)
      Evaluates the rules without reserved targets, see evaluate(FWObservable, Collection).
      Parameters:
      aObservable - the parameters; the results are set here (without notification)
      Returns:
      the results by target, in order of evaluation