com.hazelcast.jet.core

## Class ResettableSingletonTraverser<T>

- java.lang.Object
- - com.hazelcast.jet.core.ResettableSingletonTraverser<T>

- Type Parameters:
    `T` - item type
  All Implemented Interfaces:
    Traverser<T>, Consumer<T>

      public class ResettableSingletonTraverser<T>
      extends Object
      implements Traverser<T>, Consumer<T>

  Traverses over a single item which can be set from the outside, by using this traverser as a `Consumer<T>`. Another item can be set at any time and the subsequent `next()` call will consume it. However, if this traverser already has an item, it is illegal to set another one before consuming it.

  See `AppendableTraverser` if you have more items to traverse.

  Since:
    3.0

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ResettableSingletonTraverser()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `accept(T item)` Resets this traverser so that the following `next()` call will return the item supplied here.
    `T` | `next()` Returns the next item, removing it from this traverser.

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

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

    - ### Methods inherited from interface com.hazelcast.jet.Traverser

      `append, dropWhile, filter, flatMap, map, onFirstNull, peek, prepend, takeWhile`

    - ### Methods inherited from interface java.util.function.Consumer

      `andThen`

- - ### Constructor Detail

    - #### ResettableSingletonTraverser

          public ResettableSingletonTraverser()

  - ### Method Detail

    - #### next

          public T next()

      Description copied from interface: `Traverser`
      Returns the next item, removing it from this traverser. If no item is available, returns `null`. If this traverser is null-terminated, getting a `null` means it's exhausted and will keep returning `null` forever. Otherwise, trying again later may produce one.
      Specified by:
        `next` in interface `Traverser<T>`

    - #### accept

          public void accept(@Nullable
                             T item)

      Resets this traverser so that the following `next()` call will return the item supplied here. If the traverser already has an item, it is illegal to call this method until that item is consumed by calling `next()`.
      Specified by:
        `accept` in interface `Consumer<T>`
      Parameters:
        `item` - the item to return from `next()`

Copyright © 2019. All rights reserved.