Class AbstractArithmeticOperator

java.lang.Object
org.projog.core.math.AbstractArithmeticOperator
All Implemented Interfaces:
KnowledgeBaseConsumer, ArithmeticOperator, PreprocessableArithmeticOperator
Direct Known Subclasses:
AbstractBinaryArithmeticOperator, AbstractBinaryIntegerArithmeticOperator, AbstractUnaryArithmeticOperator, Divide, Max, Min, Random, Round

public abstract class AbstractArithmeticOperator extends Object implements PreprocessableArithmeticOperator, KnowledgeBaseConsumer
  • Constructor Details

    • AbstractArithmeticOperator

      public AbstractArithmeticOperator()
  • Method Details

    • setKnowledgeBase

      public final void setKnowledgeBase(KnowledgeBase kb)
      Provides a reference to a KnowledgeBase.

      Meaning this object will always have access to a KnowledgeBase by the time its calculate method is invoked.

      Specified by:
      setKnowledgeBase in interface KnowledgeBaseConsumer
    • calculate

      public final Numeric calculate(Term term)
      Description copied from interface: ArithmeticOperator
      Returns the result of the calculation using the specified arguments.
      Specified by:
      calculate in interface ArithmeticOperator
      Parameters:
      term - the arguments to use in the calculation
      Returns:
      the result of the calculation using the specified arguments
    • calculate

      protected Numeric calculate(Numeric n)
    • calculate

      protected Numeric calculate(Numeric n1, Numeric n2)
    • preprocess

      public final ArithmeticOperator preprocess(Term expression)
      Specified by:
      preprocess in interface PreprocessableArithmeticOperator
    • isPure

      protected boolean isPure()
      Indicates if this operator is pure and so can be preprocessed.

      An operator is pure if multiple calls with identical arguments always produce the same result.

      Returns:
      true if pure and so can be preprocessed, else false