org.eclipse.ocl.examples.library.numeric
Class AbstractNumericBinaryOperation

java.lang.Object
  extended by org.eclipse.ocl.examples.domain.library.AbstractFeature
      extended by org.eclipse.ocl.examples.domain.library.AbstractOperation
          extended by org.eclipse.ocl.examples.domain.library.AbstractBinaryOperation
              extended by org.eclipse.ocl.examples.library.numeric.AbstractNumericBinaryOperation
All Implemented Interfaces:
LibraryBinaryOperation, LibraryFeature, LibraryOperation
Direct Known Subclasses:
NumericDivideOperation, NumericDivOperation, NumericGreaterThanEqualOperation, NumericGreaterThanOperation, NumericLessThanEqualOperation, NumericLessThanOperation, NumericMaxOperation, NumericMinOperation, NumericMinusOperation, NumericModOperation, NumericPlusOperation, NumericTimesOperation

public abstract class AbstractNumericBinaryOperation
extends AbstractBinaryOperation

AbstractNumericBinaryOperation dispatches a binary library operation to matching-type-specific call-backs.


Constructor Summary
AbstractNumericBinaryOperation()
           
 
Method Summary
 Value evaluate(DomainEvaluator evaluator, DomainType returnType, Value left, Value right)
          Return the result of evaluating the operation on left and right arguments.
protected
<T extends java.lang.Number & java.lang.Comparable<T>>
java.lang.Object
evaluate(DomainEvaluator evaluator, T left, T right)
          Return the result of evaluating the operation on left and right which are both of the same derived Number type.
protected abstract  Value evaluateInteger(DomainEvaluator evaluator, IntegerValue left, IntegerValue right)
          Evaluate an operation for which both left and right are Integer.
protected  Value evaluateReal(DomainEvaluator evaluator, RealValue left, RealValue right)
          Evaluate an operation for which both left and right are Real.
protected  Value evaluateUnlimited(DomainEvaluator evaluator, Value left, Value right)
          Evaluate an operation for which at least one of left and right are unlimited and for which neither left nor right are invalid or null.
 
Methods inherited from class org.eclipse.ocl.examples.domain.library.AbstractBinaryOperation
evaluate
 
Methods inherited from class org.eclipse.ocl.examples.domain.library.AbstractOperation
argumentsMayBeInvalid
 
Methods inherited from class org.eclipse.ocl.examples.domain.library.AbstractFeature
getLibraryValidator, getValidator
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.eclipse.ocl.examples.domain.library.LibraryOperation
argumentsMayBeInvalid
 
Methods inherited from interface org.eclipse.ocl.examples.domain.library.LibraryFeature
getValidator
 

Constructor Detail

AbstractNumericBinaryOperation

public AbstractNumericBinaryOperation()
Method Detail

evaluate

public Value evaluate(DomainEvaluator evaluator,
                      DomainType returnType,
                      Value left,
                      Value right)
               throws InvalidValueException
Description copied from interface: LibraryBinaryOperation
Return the result of evaluating the operation on left and right arguments. An invalid return may be indicated by throwing an exception returning Java null or OCL invalid.

Returns:
the evaluated value
Throws:
InvalidValueException

evaluateInteger

protected abstract Value evaluateInteger(DomainEvaluator evaluator,
                                         IntegerValue left,
                                         IntegerValue right)
                                  throws InvalidValueException
Evaluate an operation for which both left and right are Integer.

Parameters:
left - argument
right - argument
Returns:
result
Throws:
InvalidValueException

evaluateReal

protected Value evaluateReal(DomainEvaluator evaluator,
                             RealValue left,
                             RealValue right)
                      throws InvalidValueException
Evaluate an operation for which both left and right are Real.

Parameters:
left - argument
right - argument
Returns:
result
Throws:
InvalidValueException

evaluateUnlimited

protected Value evaluateUnlimited(DomainEvaluator evaluator,
                                  Value left,
                                  Value right)
                           throws InvalidValueException
Evaluate an operation for which at least one of left and right are unlimited and for which neither left nor right are invalid or null.

Parameters:
left - argument
right - argument
Returns:
result
Throws:
InvalidValueException

evaluate

protected <T extends java.lang.Number & java.lang.Comparable<T>> java.lang.Object evaluate(DomainEvaluator evaluator,
                                                                                          T left,
                                                                                          T right)
                             throws InvalidValueException
Return the result of evaluating the operation on left and right which are both of the same derived Number type. A null return or an exception may be used for invalid.

Throws:
InvalidValueException