Package ru.ispras.fortress.calculator
Interface Operation<OperationIdT extends java.lang.Enum<OperationIdT>>
-
- Type Parameters:
OperationIdT
- Type of the enumeration that describes a group of operations.
- All Known Implementing Classes:
CalculatorOperation
public interface Operation<OperationIdT extends java.lang.Enum<OperationIdT>>
TheOperation
interface is a contract for objects implementing operations on data objects.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description 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.
-
-
-
Method Detail
-
getOperationId
OperationIdT getOperationId()
Returns the identifier of the operation.- Returns:
- Operation identifier.
-
getOperationArity
ArityRange getOperationArity()
Returns the range that describes the allowed arity of the operation.- Returns:
- Range of operation arity.
-
calculate
Data calculate(Data... operands)
Performs an operation on the specified operands.- Parameters:
operands
- A variable array of operands.- Returns:
- Data object containing the calculated value.
- Throws:
java.lang.IllegalArgumentException
- ifnull
is passed to the method.java.lang.UnsupportedOperationException
- if the operation requires a number of arguments which is different from the one passed to the method.
-
validTypes
boolean validTypes(Data... operands)
Performs type check on the specified operands.- Parameters:
operands
- A variable array of operands.- Returns:
true
if operand types are valid for the operation orfalse
otherwise.
-
-