org.apache.ignite.internal.util.lang

## Class GridIterableAdapter<T>

- java.lang.Object
- - org.apache.ignite.internal.util.lang.GridIterableAdapter<T>

All Implemented Interfaces:
  Serializable, Iterable<T>, Iterator<T>, GridSerializableIterator<T>, GridIterable<T>, GridIterator<T>

    public class GridIterableAdapter<T>
    extends Object
    implements GridIterable<T>

Convenient adapter for "rich" iterable interface.

See Also:
  Serialized Form

### Constructor Summary

Constructors
Constructor and Description
`GridIterableAdapter(Iterator<T> impl)` Creates adapter with given iterator implementation.

### Method Summary

Methods
`boolean` `hasNext()`
`boolean` `hasNextX()` This method is the same as `Iterator.hasNext()`, but allows for failure with exception.
`GridIterator<T>` `iterator()` Returns `GridIterator` which extends regular `Iterator` interface and adds methods that account for possible failures in cases when iterating over data that has been partially received over network.
`T` `next()`
`T` `nextX()` This method is the same as `Iterator.next()`, but allows for failure with exception.
`void` `remove()`
`void` `removeX()` This method is the same as `Iterator.remove()`, but allows for failure with exception.
`String` `toString()`

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

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

### Constructor Detail

#### GridIterableAdapter

    public GridIterableAdapter(Iterator<T> impl)

Creates adapter with given iterator implementation.

Parameters:
  `impl` - Iterator implementation.

### Method Detail

#### iterator

    public GridIterator<T> iterator()

Returns `GridIterator` which extends regular `Iterator` interface and adds methods that account for possible failures in cases when iterating over data that has been partially received over network.

Specified by:
  `iterator` in interface `Iterable<T>`
Specified by:
  `iterator` in interface `GridIterable<T>`
Returns:
  Instance of new `GridIterator`.

#### hasNext

    public boolean hasNext()

Specified by:
  `hasNext` in interface `Iterator<T>`

#### hasNextX

    public boolean hasNextX()
                     throws IgniteCheckedException

This method is the same as `Iterator.hasNext()`, but allows for failure with exception. Often iterators are used to iterate through values that have not or have partially been received from remote nodes, and need to account for possible network failures, rather than just returning `false` out of `Iterator.hasNext()` method.

Specified by:
  `hasNextX` in interface `GridIterator<T>`
Returns:
  `True` if iterator contains more elements.
Throws:
  `IgniteCheckedException` - If no more elements can be returned due to some failure, like a network error for example.
See Also:
  `Iterator.hasNext()`

#### next

    public T next()

Specified by:
  `next` in interface `Iterator<T>`

#### nextX

    public T nextX()
            throws IgniteCheckedException

This method is the same as `Iterator.next()`, but allows for failure with exception. Often iterators are used to iterate through values that have not or have partially been received from remote nodes, and need to account for possible network failures, rather than throwing `NoSuchElementException` runtime exception.s

Specified by:
  `nextX` in interface `GridIterator<T>`
Returns:
  `True` if iterator contains more elements.
Throws:
  `IgniteCheckedException` - If no more elements can be returned due to some failure, like a network error for example.
See Also:
  `Iterator.next()`

#### remove

    public void remove()

Specified by:
  `remove` in interface `Iterator<T>`

#### removeX

    public void removeX()
                 throws IgniteCheckedException

This method is the same as `Iterator.remove()`, but allows for failure with exception.

Specified by:
  `removeX` in interface `GridIterator<T>`
Throws:
  `IgniteCheckedException` - If failed.

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`

2015 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 1.3.0-incubating
Release Date | : July 10 2015