org.springframework.batch.sample.domain.trade.internal

## Class TradeWriter

- java.lang.Object
- - org.springframework.batch.item.ItemStreamSupport
  - - org.springframework.batch.sample.domain.trade.internal.TradeWriter

- All Implemented Interfaces:
    ItemStream, ItemWriter<Trade>

      public class TradeWriter
      extends ItemStreamSupport
      implements ItemWriter<Trade>

  Delegates the actual writing to custom DAO delegate. Allows configurable exception raising for testing skip and restart.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.lang.String` | `TOTAL_AMOUNT_KEY`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `TradeWriter()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.math.BigDecimal` | `getTotalPrice()`
    `void` | `open(ExecutionContext executionContext)` No-op.
    `void` | `setDao(TradeDao dao)`
    `void` | `setFailingCustomers(java.util.List<java.lang.String> failingCustomers)` Public setter for the the customers on which failure should occur.
    `void` | `update(ExecutionContext executionContext)` Return empty `ExecutionContext`.
    `void` | `updateTotalPrice(java.util.List<Trade> trades)`
    `void` | `write(java.util.List<? extends Trade> trades)` Process the supplied data element.

    - ### Methods inherited from class org.springframework.batch.item.ItemStreamSupport

      `close, getExecutionContextKey, setExecutionContextName, setName`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### TOTAL_AMOUNT_KEY

          public static final java.lang.String TOTAL_AMOUNT_KEY

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### TradeWriter

          public TradeWriter()

  - ### Method Detail

    - #### write

          public void write(java.util.List<? extends Trade> trades)

      Description copied from interface: `ItemWriter`
      Process the supplied data element. Will not be called with any null items in normal operation.
      Specified by:
        `write` in interface `ItemWriter<Trade>`
      Parameters:
        `trades` - items to be written

    - #### updateTotalPrice

          public void updateTotalPrice(java.util.List<Trade> trades)

    - #### open

          public void open(ExecutionContext executionContext)

      Description copied from class: `ItemStreamSupport`
      No-op.
      Specified by:
        `open` in interface `ItemStream`
      Overrides:
        `open` in class `ItemStreamSupport`
      Parameters:
        `executionContext` - current step's `ExecutionContext`. Will be the executionContext from the last run of the step on a restart.
      See Also:
        `ItemStream.open(ExecutionContext)`

    - #### update

          public void update(ExecutionContext executionContext)

      Description copied from class: `ItemStreamSupport`
      Return empty `ExecutionContext`.
      Specified by:
        `update` in interface `ItemStream`
      Overrides:
        `update` in class `ItemStreamSupport`
      Parameters:
        `executionContext` - to be updated
      See Also:
        `ItemStream.update(ExecutionContext)`

    - #### getTotalPrice

          public java.math.BigDecimal getTotalPrice()

    - #### setDao

          public void setDao(TradeDao dao)

    - #### setFailingCustomers

          public void setFailingCustomers(java.util.List<java.lang.String> failingCustomers)

      Public setter for the the customers on which failure should occur.
      Parameters:
        `failingCustomers` - The customers to fail on