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>>
    The Operation interface is a contract for objects implementing operations on data objects.
    • 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 - if null 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 or false otherwise.