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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate final classprivate final class -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected Numericprotected Numericfinal NumericReturns the result of the calculation using the specified arguments.private IllegalArgumentExceptioncreateWrongNumberOfArgumentsException(int numberOfArguments) protected booleanisPure()Indicates if this operator is pure and so can be preprocessed.final ArithmeticOperatorpreprocess(Term expression) private ArithmeticOperatorpreprocessBinaryOperator(Term argument1, Term argument2) private ArithmeticOperatorpreprocessUnaryOperator(Term argument) final voidProvides a reference to aKnowledgeBase.
-
Field Details
-
operators
-
-
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:
args- the arguments to use in the calculation- Returns:
- the result of the calculation using the specified arguments
-
calculate
-
calculate
-
createWrongNumberOfArgumentsException
-
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
-
preprocessUnaryOperator
-
preprocessBinaryOperator
-