Package ru.ispras.fortress.calculator
Class CompositeCalculator
- java.lang.Object
-
- ru.ispras.fortress.calculator.CompositeCalculator
-
- All Implemented Interfaces:
CalculatorEngine
public class CompositeCalculator extends java.lang.Object implements CalculatorEngine
-
-
Constructor Summary
Constructors Constructor Description CompositeCalculator(java.util.List<CalculatorEngine> engines)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Data
calculate(java.lang.Enum<?> opId, Data... operands)
Performs calculation by applying the specified operation to the operands.boolean
isSupported(java.lang.Enum<?> opId, Data... operands)
Checks whether the specified operation is supported for the provided operands.
-
-
-
Constructor Detail
-
CompositeCalculator
public CompositeCalculator(java.util.List<CalculatorEngine> engines)
-
-
Method Detail
-
isSupported
public boolean isSupported(java.lang.Enum<?> opId, Data... operands)
Description copied from interface:CalculatorEngine
Checks whether the specified operation is supported for the provided operands. Operation identifier and operand types are taken into consideration.- Specified by:
isSupported
in interfaceCalculatorEngine
- Parameters:
opId
- Operator identifier. Identifies an operation within a group.operands
- Array of operands.- Returns:
true
if the operation is supported for the given operand types orfalse
if it is not supported or its invariants are violated (e.g. operand types do not match).
-
calculate
public Data calculate(java.lang.Enum<?> opId, Data... operands)
Description copied from interface:CalculatorEngine
Performs calculation by applying the specified operation to the operands.- Specified by:
calculate
in interfaceCalculatorEngine
- Parameters:
opId
- Operator identifier. Identifies an operation within a group.operands
- Array of operands.- Returns:
- Data object holding the calculated value.
-
-