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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected Numericprotected Numericfinal NumericReturns the result of the calculation using the specified arguments.protected booleanisPure()Indicates if this operator is pure and so can be preprocessed.final ArithmeticOperatorpreprocess(Term expression) final voidProvides a reference to aKnowledgeBase.
-
Constructor Details
-
AbstractArithmeticOperator
public AbstractArithmeticOperator()
-
-
Method Details
-
setKnowledgeBase
Provides a reference to aKnowledgeBase.Meaning this object will always have access to a
KnowledgeBaseby the time itscalculatemethod is invoked.- Specified by:
setKnowledgeBasein interfaceKnowledgeBaseConsumer
-
calculate
Description copied from interface:ArithmeticOperatorReturns the result of the calculation using the specified arguments.- Specified by:
calculatein interfaceArithmeticOperator- Parameters:
term- the arguments to use in the calculation- Returns:
- the result of the calculation using the specified arguments
-
calculate
-
calculate
-
preprocess
- Specified by:
preprocessin interfacePreprocessableArithmeticOperator
-
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
-