OperationId
- Class of the enumeration that specifies operations included in the operation
group. An operation group object can hold only operations that are members of the same
group and are described as elements of the same enumeration.public final class OperationGroup<OperationId extends java.lang.Enum<OperationId>> extends java.lang.Object implements CalculatorEngine
Constructor and Description |
---|
OperationGroup()
Constructor for an operation group object.
|
Modifier and Type | Method and Description |
---|---|
Data |
calculate(java.lang.Enum<?> operationId,
Data... operands)
Performs calculation by applying the specified operation to the operands.
|
boolean |
isSupported(java.lang.Enum<?> operationId,
Data... operands)
Checks whether the specified operation is supported for the provided operands.
|
static <T extends java.lang.Enum<T>> |
operationMap(java.lang.Class<T> c,
java.util.Collection<? extends Operation<T>> operations) |
void |
registerOperations(DataTypeId typeId,
java.util.Map<OperationId,Operation<OperationId>> operationsForType)
Registers a group of operators that perform calculations on a specific data type.
|
public OperationGroup()
public final void registerOperations(DataTypeId typeId, java.util.Map<OperationId,Operation<OperationId>> operationsForType)
typeId
- Data type identifier.operationsForType
- A map of operation on the specified data type. Key is the operation
identifier and value is the operation implementation.java.lang.IllegalArgumentException
- if any of the parameters equals null
.public final boolean isSupported(java.lang.Enum<?> operationId, Data... operands)
isSupported
in interface CalculatorEngine
operationId
- Operator identifier. Identifies an operation within a group.operands
- Array of operands.true
if the operation is supported for the given operand types or false
if it is not supported or its invariants are violated (e.g. operand types do not
match).java.lang.IllegalArgumentException
- if any of the parameters equals null
.public final Data calculate(java.lang.Enum<?> operationId, Data... operands)
calculate
in interface CalculatorEngine
operationId
- Operator identifier. Identifies an operation within a group.operands
- Array of operands.java.lang.IllegalArgumentException
- if any of the parameters equals null
.java.lang.UnsupportedOperationException
- if the specified operation is not supported for the
provided operands.