Package ru.ispras.fortress.calculator
Interface CalculatorEngine
-
- All Known Implementing Classes:
CompositeCalculator
,OperationGroup
public interface CalculatorEngine
TheCalculatorEngine
interface is an interface to be implemented by all calculator engines. Calculator engines perform calculations using operations united into a group. Operation groups are represented by corresponding enumerations that list supported operations.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Data
calculate(java.lang.Enum<?> operatorId, Data... operands)
Performs calculation by applying the specified operation to the operands.boolean
isSupported(java.lang.Enum<?> operatorId, Data... operands)
Checks whether the specified operation is supported for the provided operands.
-
-
-
Method Detail
-
isSupported
boolean isSupported(java.lang.Enum<?> operatorId, Data... operands)
Checks whether the specified operation is supported for the provided operands. Operation identifier and operand types are taken into consideration.- Parameters:
operatorId
- 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
Data calculate(java.lang.Enum<?> operatorId, Data... operands)
Performs calculation by applying the specified operation to the operands.- Parameters:
operatorId
- Operator identifier. Identifies an operation within a group.operands
- Array of operands.- Returns:
- Data object holding the calculated value.
- Throws:
java.lang.UnsupportedOperationException
- if the operation is not supported or its invariants are violated (e.g. operand types do not match).
-
-