korlov42 commented on code in PR #739: URL: https://github.com/apache/ignite-3/pull/739#discussion_r841462683
########## modules/core/src/main/java/org/apache/ignite/internal/util/Cursor.java: ########## @@ -25,5 +26,40 @@ * @param <T> Type of elements. */ public interface Cursor<T> extends Iterator<T>, Iterable<T>, AutoCloseable { + /** {@inheritDoc} */ + @Override + default Iterator<T> iterator() { + return this; + } + /** + * Creates an iterator based cursor. + * + * @param it Iterator. + * @param <T> Type of elements in iterator. + * @return Cursor. + */ + static <T> Cursor<T> fromIterator(Iterator<? extends T> it) { + return new Cursor<T>() { + /** {@inheritDoc} */ + @Override + public void close() throws Exception { + if (it instanceof Closeable) { Review Comment: I believe `AutoCloseable` fits better here. The logic is simple: since `Cursor` extends `AutoCloseable`, I would expect that wrapped iterator which extends `AutoCloseable` as well will be closed by invocation of 'close()' on the cursor -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@ignite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org