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

java.lang.Object
  extended by org.eclipse.ocl.examples.library.AbstractFeature
      extended by org.eclipse.ocl.examples.library.AbstractOperation
          extended by org.eclipse.ocl.examples.library.AbstractBinaryOperation
              extended by org.eclipse.ocl.examples.library.numeric.AbstractNumericBinaryOperation
All Implemented Interfaces:
LibraryBinaryOperation, LibraryFeature, LibraryOperation, CallableImplementation, Value.BinaryOperation
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.

Since:
3.1

Constructor Summary
AbstractNumericBinaryOperation()
           
 
Method Summary
protected
<T extends java.lang.Number & java.lang.Comparable<T>>
java.lang.Object
evaluate(ValueFactory valueFactory, T left, T right)
          Return the result of evaluating the operation on left and right which are both of the same derived Number type.
 Value evaluate(ValueFactory valueFactory, Value left, Value right)
          Return the result of evaluating the operation on left and right arguments.
protected  Value evaluateInteger(ValueFactory valueFactory, IntegerValue left, IntegerValue right)
          Evaluate an operation for which both left and right are Integer.
protected  Value evaluateReal(ValueFactory valueFactory, RealValue left, RealValue right)
          Evaluate an operation for which both left and right are Real.
protected  Value evaluateUnlimited(ValueFactory valueFactory, 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.library.AbstractBinaryOperation
evaluate
 
Methods inherited from class org.eclipse.ocl.examples.library.AbstractOperation
evaluate, evaluateArgument, getNumArguments
 
Methods inherited from class org.eclipse.ocl.examples.library.AbstractFeature
validate
 
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.pivot.evaluation.CallableImplementation
evaluate, validate
 

Constructor Detail

AbstractNumericBinaryOperation

public AbstractNumericBinaryOperation()
Method Detail

evaluate

public Value evaluate(ValueFactory valueFactory,
                      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.

left - left argument
right - argument
Returns:
the evaluated value
Throws:
InvalidValueException

evaluateInteger

protected Value evaluateInteger(ValueFactory valueFactory,
                                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(ValueFactory valueFactory,
                             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(ValueFactory valueFactory,
                                  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(ValueFactory valueFactory,
                                                                                          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