Package ru.ispras.fortress.calculator
Class CalculatorOperation<OperationIdT extends java.lang.Enum<OperationIdT>>
- java.lang.Object
-
- ru.ispras.fortress.calculator.CalculatorOperation<OperationIdT>
-
-
Constructor Summary
Constructors Constructor Description CalculatorOperation(OperationIdT id, ArityRange arity)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract Data
calculate(Data... operands)
Performs an operation on the specified operands.ArityRange
getOperationArity()
Returns the range that describes the allowed arity of the operation.OperationIdT
getOperationId()
Returns the identifier of the operation.boolean
validTypes(Data... operands)
Performs type check on the specified operands.
-
-
-
Constructor Detail
-
CalculatorOperation
public CalculatorOperation(OperationIdT id, ArityRange arity)
-
-
Method Detail
-
getOperationId
public OperationIdT getOperationId()
Description copied from interface:Operation
Returns the identifier of the operation.- Specified by:
getOperationId
in interfaceOperation<OperationIdT extends java.lang.Enum<OperationIdT>>
- Returns:
- Operation identifier.
-
getOperationArity
public ArityRange getOperationArity()
Description copied from interface:Operation
Returns the range that describes the allowed arity of the operation.- Specified by:
getOperationArity
in interfaceOperation<OperationIdT extends java.lang.Enum<OperationIdT>>
- Returns:
- Range of operation arity.
-
validTypes
public boolean validTypes(Data... operands)
Description copied from interface:Operation
Performs type check on the specified operands.- Specified by:
validTypes
in interfaceOperation<OperationIdT extends java.lang.Enum<OperationIdT>>
- Parameters:
operands
- A variable array of operands.- Returns:
true
if operand types are valid for the operation orfalse
otherwise.
-
calculate
public abstract Data calculate(Data... operands)
Description copied from interface:Operation
Performs an operation on the specified operands.- Specified by:
calculate
in interfaceOperation<OperationIdT extends java.lang.Enum<OperationIdT>>
- Parameters:
operands
- A variable array of operands.- Returns:
- Data object containing the calculated value.
-
-