de.caff.generics.handler

## Class ConvertingFragileLoopItemHandler<T,S>

- java.lang.Object
- - de.caff.generics.handler.ConvertingFragileLoopItemHandler<T,S>

- All Implemented Interfaces:
    FragileLoopItemHandler<S,TypeConverterException>, LoopHandler

      public abstract class ConvertingFragileLoopItemHandler<T,S>
      extends java.lang.Object
      implements FragileLoopItemHandler<S,TypeConverterException>

  A fragile loop item handler which converts incoming items.
  Author:
    Rammi
  See Also:
    `ConvertingLoopItemHandler`, `DeletingLoopItemHandler`, `MultiConvertingLoopItemHandler`, `DeletingFragileLoopItemHandler`, `MultiConvertingFragileLoopItemHandler`, `FilteringLoopItemHandler`

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected FragileTypeConverter<T,S>` | `typeConverter`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `ConvertingFragileLoopItemHandler(FragileTypeConverter<T,S> typeConverter)` Constructor.

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `afterFinish()` Called after the loop has finished.
    `void` | `beforeStart()` Called before the loop is started.
    `boolean` | `handle(S item)` Handle an item.
    `protected abstract boolean` | `handleConverted(T converted, S incoming)` Handle the converted item.

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

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

- - ### Field Detail

    - #### typeConverter

          protected final FragileTypeConverter<T,S> typeConverter

  - ### Constructor Detail

    - #### ConvertingFragileLoopItemHandler

          protected ConvertingFragileLoopItemHandler(@NotNull
                                                     FragileTypeConverter<T,S> typeConverter)

      Constructor.
      Parameters:
        `typeConverter` - type converter which converts the incoming types to the collected types.

  - ### Method Detail

    - #### handleConverted

          protected abstract boolean handleConverted(T converted,
                                                     S incoming)
                                              throws java.lang.Exception

      Handle the converted item.
      Parameters:
        `converted` - converted item
        `incoming` - incoming item
      Returns:
        `true` go on with loop
        `false` break loop
      Throws:
        `java.lang.Exception` - if converter throws it

    - #### handle

          public boolean handle(S item)
                         throws TypeConverterException

      Handle an item.
      Specified by:
        `handle` in interface `FragileLoopItemHandler<S,TypeConverterException>`
      Parameters:
        `item` - item to handle
      Returns:
        `true` go on with loop
        `false` break loop
      Throws:
        `TypeConverterException` - on type conversion errors

    - #### beforeStart

          public void beforeStart()

      Called before the loop is started.
      Specified by:
        `beforeStart` in interface `LoopHandler`

    - #### afterFinish

          public void afterFinish()

      Called after the loop has finished.
      Specified by:
        `afterFinish` in interface `LoopHandler`