de.caff.generics.handler

## Class FindFirstIndexHandler<T>

- java.lang.Object
- - de.caff.generics.handler.FindFirstIndexHandler<T>

- All Implemented Interfaces:
    LoopHandler, LoopItemHandler<T>

      public class FindFirstIndexHandler<T>
      extends java.lang.Object
      implements LoopItemHandler<T>

  Handler which finds the index of an item in a loop.
  Author:
    Rammi

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `FindFirstIndexHandler(T object)` Constructor.
    `FindFirstIndexHandler(T object, int startIndex)` Constructor.

  - ### Method Summary

    All Methods Instance 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.
    `int` | `getFoundIndex()` Get the index where the object was found.
    `T` | `getFoundItem()` Get the item which was found.
    `T` | `getSearchObject()` Get the looked up object.
    `boolean` | `handle(T item)` Handle an item.

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

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

- - ### Constructor Detail

    - #### FindFirstIndexHandler

          public FindFirstIndexHandler(@Nullable
                                       T object)

      Constructor. This searches from the beginning.
      Parameters:
        `object` - object to look for

    - #### FindFirstIndexHandler

          public FindFirstIndexHandler(@Nullable
                                       T object,
                                       int startIndex)

      Constructor. This searches from the given start index.
      Parameters:
        `object` - object to look for
        `startIndex` - start index from where to look

  - ### Method Detail

    - #### handle

          public boolean handle(T item)

      Handle an item.
      Specified by:
        `handle` in interface `LoopItemHandler<T>`
      Parameters:
        `item` - item to handle
      Returns:
        `true` go on with loop
        `false` break loop

    - #### 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`

    - #### getFoundIndex

          public int getFoundIndex()

      Get the index where the object was found.
      Returns:
        first found index or `-1`

    - #### getFoundItem

          @Nullable
          public T getFoundItem()

      Get the item which was found.
      Returns:
        first found index or `null`

    - #### getSearchObject

          @Nullable
          public T getSearchObject()

      Get the looked up object.
      Returns:
        first found index or `null`