Package ru.ewc.decita

Class Rule

java.lang.Object
ru.ewc.decita.Rule

public final class Rule extends Object
I am a single Rule (i.e. the column in the decision table). My main responsibility is to check whether all my second-order Conditions are true and if so - compute my outcomes.
Since:
0.1
  • Constructor Details

    • Rule

      public Rule()
  • Method Details

    • withCondition

      public Rule withCondition(Condition condition)
      Adds a Condition to this rule.
      Parameters:
      condition - The Condition to add.
      Returns:
      Itself, in order to implement fluent API.
    • withOutcome

      public Rule withOutcome(String outcome, String value)
      Adds an outcome to this rule.
      Parameters:
      outcome - The key of an outcome to add.
      value - The string representation of an outcome's value to add.
      Returns:
      Itself, in order to implement fluent API.
    • isComputed

      public boolean isComputed()
      Checks whether this rule is computed, i.e. all of its Conditions were resolved successfully.
      Returns:
      True if the rule is computed.
    • isEliminated

      public boolean isEliminated()
      Checks whether this rule is not satisfied (i.e. any of its Conditions resolved to false).
      Returns:
      True if the rule is dissatisfied.
    • isSatisfied

      public boolean isSatisfied()
      Checks whether this rule is satisfied (i.e. all of its Conditions are computed and resolved to true).
      Returns:
      True if the rule is satisfied.
    • check

      public void check(ComputationContext context) throws DecitaException
      Checks if this Rule is satisfied.
      Parameters:
      context - The ComputationContext's instance.
      Throws:
      DecitaException - If the rule's Conditions could not be resolved.
    • outcome

      public Map<String,String> outcome()
      Returns this rule outcomes.
      Returns:
      The simple dictionary, containing all this rule's outcomes.