org.apache.cayenne.access.jdbc

## Class DistinctResultIterator<T>

- java.lang.Object
- - org.apache.cayenne.access.jdbc.DistinctResultIterator<T>

- All Implemented Interfaces:
    AutoCloseable, Iterable<T>, ResultIterator<T>

      public class DistinctResultIterator<T>
      extends Object
      implements ResultIterator<T>

  A ResultIterator that does in-memory filtering of rows to return only distinct rows. Distinct comparison is done by comparing ObjectIds created from each row. Internally DistinctResultIterator wraps another ResultIterator that provides the actual rows.
  Since:
    3.0

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected boolean` | `compareFullRows`
    `protected DbEntity` | `defaultEntity`
    `protected ResultIterator<T>` | `delegate`
    `protected Set<Object>` | `fetchedIds`
    `protected T` | `nextDataRow`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DistinctResultIterator(ResultIterator<T> delegate, DbEntity defaultEntity, boolean compareFullRows)` Creates new DistinctResultIterator wrapping another ResultIterator.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `List<T>` | `allRows()` Returns all yet unread rows from ResultSet without closing it.
    `void` | `close()` Closes underlying ResultIterator.
    `boolean` | `hasNextRow()` Returns true if there is at least one more record that can be read from the iterator.
    `Iterator<T>` | `iterator()`
    `T` | `nextRow()` Returns the next result row that is, depending on the query, may be a scalar value, a DataRow, or an Object[] array containing a mix of scalars and DataRows.
    `void` | `skipRow()` Goes past current row.

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

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

    - ### Methods inherited from interface java.lang.Iterable

      `forEach, spliterator`

- - ### Field Detail

    - #### delegate

          protected ResultIterator<T> delegate

    - #### fetchedIds

          protected Set<Object> fetchedIds

    - #### nextDataRow

          protected T nextDataRow

    - #### defaultEntity

          protected DbEntity defaultEntity

    - #### compareFullRows

          protected boolean compareFullRows

  - ### Constructor Detail

    - #### DistinctResultIterator

          public DistinctResultIterator(ResultIterator<T> delegate,
                                        DbEntity defaultEntity,
                                        boolean compareFullRows)

      Creates new DistinctResultIterator wrapping another ResultIterator.
      Parameters:
        `delegate` - actual result iterator, that will be decorated by this DistinctResultIterator
        `defaultEntity` - an entity needed to build ObjectIds for distinct comparison.

  - ### Method Detail

    - #### iterator

          public Iterator<T> iterator()

      Specified by:
        `iterator` in interface `Iterable<T>`
      Since:
        4.0

    - #### close

          public void close()

      Closes underlying ResultIterator.
      Specified by:
        `close` in interface `AutoCloseable`
      Specified by:
        `close` in interface `ResultIterator<T>`

    - #### allRows

          public List<T> allRows()

      Description copied from interface: `ResultIterator`
      Returns all yet unread rows from ResultSet without closing it.
      Specified by:
        `allRows` in interface `ResultIterator<T>`
      Since:
        3.0

    - #### hasNextRow

          public boolean hasNextRow()

      Description copied from interface: `ResultIterator`
      Returns true if there is at least one more record that can be read from the iterator.
      Specified by:
        `hasNextRow` in interface `ResultIterator<T>`

    - #### nextRow

          public T nextRow()

      Description copied from interface: `ResultIterator`
      Returns the next result row that is, depending on the query, may be a scalar value, a DataRow, or an Object[] array containing a mix of scalars and DataRows.
      Specified by:
        `nextRow` in interface `ResultIterator<T>`

    - #### skipRow

          public void skipRow()

      Description copied from interface: `ResultIterator`
      Goes past current row. If the row is not needed, this may save some time on data conversion.
      Specified by:
        `skipRow` in interface `ResultIterator<T>`
      Since:
        3.0

Copyright © 2001–2021 Apache Cayenne. All rights reserved.