Operation
Date: 2016-02-29

de.zib.scalaris.operations

## Interface Operation

- All Known Subinterfaces:
    TransactionOperation, TransactionSingleOpOperation
  All Known Implementing Classes:
    AddDelOnListOp, AddOnNrOp, CommitOp, PartialReadOp, ReadOp, ReadRandomFromListOp, ReadSublistOp, TestAndSetOp, WriteOp

      public interface Operation

  Generic interface for operations which can be added to a request list.
  Since:
    3.14
  Version:
    3.18
  Author:
    Nico Kruber, kruber@zib.de

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `OtpErlangObject` | `getErlang(boolean compressed)` Gets the erlang representation of the operation.
    `OtpErlangString` | `getKey()` Gets the key the operation is working on (if available)
    `OtpErlangObject` | `getResult()` Gets the (raw Erlang) result set via `setResult(OtpErlangObject, boolean)`.
    `boolean` | `getResultCompressed()` Determines if the result set via `setResult(OtpErlangObject, boolean)` is compressed or not.
    `Object` | `processResult()` Processes the result set by `setResult(OtpErlangObject, boolean)`.
    `void` | `setResult(OtpErlangObject resultRaw, boolean compressed)` Sets the raw erlang result value.

- - ### Method Detail

    - #### getErlang

          OtpErlangObject getErlang(boolean compressed)

      Gets the erlang representation of the operation.
      Parameters:
        `compressed` - whether the value part in the term should be encoded, i.e. compressed into an Erlang binary, or not
      Returns:
        erlang representation for api_tx:req_list

    - #### getKey

          OtpErlangString getKey()

      Gets the key the operation is working on (if available)
      Returns:
        the key or `null`

    - #### setResult

          void setResult(OtpErlangObject resultRaw,
                       boolean compressed)

      Sets the raw erlang result value. It can be processed using `processResult()`.
      Parameters:
        `resultRaw` - the result
        `compressed` - whether the value inside the result is compressed or not
      Since:
        3.18

    - #### getResult

          OtpErlangObject getResult()

      Gets the (raw Erlang) result set via `setResult(OtpErlangObject, boolean)`.
      Returns:
        the result object or `null` if not set
      Since:
        3.18

    - #### getResultCompressed

          boolean getResultCompressed()

      Determines if the result set via `setResult(OtpErlangObject, boolean)` is compressed or not.
      Returns:
        `true` if compressed, `false` otherwise, undefined if no result was set
      Since:
        3.18

    - #### processResult

          Object processResult()
                               throws NotFoundException,
                                      KeyChangedException,
                                      NotANumberException,
                                      NotAListException,
                                      AbortException,
                                      EmptyListException,
                                      UnknownException

      Processes the result set by `setResult(OtpErlangObject, boolean)`. Note: the created value is not cached!
      Returns:
        a (potentially) read value (may be `null`)
      Throws:
        `NotFoundException` - if the requested key does not exist
        `KeyChangedException` - if the key did not match `old_value`
        `NotANumberException` - if the previously stored value was not a number
        `NotAListException` - if the previously stored value was no list
        `EmptyListException` - if the stored value is an empty list but the op requires a non-empty list
        `AbortException` - if a commit failed
        `UnknownException` - if any other error occurs
      Since:
        3.18