// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/CloseableIterator.java
// public interface CloseableIterator<E> extends Iterator<E>, AutoCloseable {
// 
//     // do not throw checked Exceptions
//     @Override
//     void close();
// 
//     static <E> CloseableIterator<E> emptyIterator() {
//         return new CloseableIterator<E>() {
//             @Override
//             public void close() {
//             }
// 
// 
//             @Override
//             public boolean hasNext() {
//                 return false;
//             }
// 
// 
//             @Override
//             public E next() {
//                 throw new NoSuchElementException();
//             }
//         };
//     }
// }
// 
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitCommit.java
// public interface GitCommit extends HasObjectId {
// 
//     @Nonnull
//     String getMessage();
// 
//     /**
//      * Gets a collection of all tags in the repository that point to this commit.
//      *
//      * @return a collection of {@link GitTag} objects (may be empty)
//      */
//     @Nonnull
//     Collection<? extends GitTag> getTags();
// 
//     /**
//      * Gets a list of the parent commits.
//      *
//      * <p>If a commit has more than one parent, the commit is a merge commit, and the second and any further
//      * parents refer to the merged branch(es).</p>
//      *
//      * @return the list of parent commits; may be empty
//      */
//     @Nonnull
//     List<? extends GitCommit> getParents();
// }
// 
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/util/io/IOBiFunction.java
// @FunctionalInterface
// public interface IOBiFunction<T, U, R> {
// 
//     /**
//      * Applies this function to the given arguments.
//      *
//      * @param t the first function argument
//      * @param u the second function argument
//      * @return the function result
//      * @throws IOException for I/O errors
//      */
//     R apply(T t, U u) throws IOException;
// 
//     /**
//      * Returns a composed function that first applies this function to
//      * its input, and then applies the {@code after} function to the result.
//      * If evaluation of either function throws an exception, it is relayed to
//      * the caller of the composed function.
//      *
//      * @param <V> the type of output of the {@code after} function, and of the
//      *           composed function
//      * @param after the function to apply after this function is applied
//      * @return a composed function that first applies this function and then
//      * applies the {@code after} function
//      * @throws NullPointerException if after is null
//      */
//     default <V> IOBiFunction<T, U, V> andThen(IOFunction<? super R, ? extends V> after) {
//         Objects.requireNonNull(after);
//         return (T t, U u) -> after.apply(apply(t, u));
//     }
// }
// 
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/util/io/IOConsumer.java
// public interface IOConsumer<T> {
// 
//     /**
//      * Performs this operation on the given argument.
//      *
//      * @param t the input argument
//      * @throws IOException for I/O errors
//      */
//     void accept(T t) throws IOException;
// 
// 
//     /**
//      * Returns a composed {@code IOConsumer} that performs, in sequence, this
//      * operation followed by the {@code after} operation. If performing either
//      * operation throws an exception, it is relayed to the caller of the
//      * composed operation.  If performing this operation throws an exception,
//      * the {@code after} operation will not be performed.
//      *
//      * @param after the operation to perform after this operation
//      * @return a composed {@code IOConsumer} that performs in sequence this
//      * operation followed by the {@code after} operation
//      * @throws NullPointerException if {@code after} is null
//      */
//     default IOConsumer<T> andThen(IOConsumer<? super T> after) {
//         Objects.requireNonNull(after);
//         return (T t) -> { accept(t); after.accept(t); };
//     }
// }
// 
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/util/io/IOFunction.java
// @FunctionalInterface
// public interface IOFunction<T, R> {
// 
//     R apply(T t) throws IOException;
// }
// 
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/util/io/IOUtils.java
// public final class IOUtils {
// 
//     private IOUtils() { }
// 
//     public static <T> T unchecked(IOCallable<T> callable) {
//         try {
//             return callable.call();
//         } catch (IOException ex) {
//             throw new RuntimeIOException(ex);
//         }
//     }
// 
//     public static void unchecked(IORunnable runnable) {
//         try {
//             runnable.run();
//         } catch (IOException ex) {
//             throw new RuntimeIOException(ex);
//         }
//     }
// }


import com.google.common.collect.AbstractIterator;
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.revwalk.RevWalk;
import org.unbrokendome.gradle.plugins.gitversion.model.CloseableIterator;
import org.unbrokendome.gradle.plugins.gitversion.model.GitCommit;
import org.unbrokendome.gradle.plugins.gitversion.util.io.IOBiFunction;
import org.unbrokendome.gradle.plugins.gitversion.util.io.IOConsumer;
import org.unbrokendome.gradle.plugins.gitversion.util.io.IOFunction;
import org.unbrokendome.gradle.plugins.gitversion.util.io.IOUtils;
package org.unbrokendome.gradle.plugins.gitversion.model.jgit;



public class JGitWalkIterator extends AbstractIterator<GitCommit> implements CloseableIterator<GitCommit> {

    private final JGitRepository repository;
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/CloseableIterator.java
// public interface CloseableIterator<E> extends Iterator<E>, AutoCloseable {
// 
//     // do not throw checked Exceptions
//     @Override
//     void close();
// 
//     static <E> CloseableIterator<E> emptyIterator() {
//         return new CloseableIterator<E>() {
//             @Override
//             public void close() {
//             }
// 
// 
//             @Override
//             public boolean hasNext() {
//                 return false;
//             }
// 
// 
//             @Override
//             public E next() {
//                 throw new NoSuchElementException();
//             }
//         };
//     }
// }
// 
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/GitCommit.java
// public interface GitCommit extends HasObjectId {
// 
//     @Nonnull
//     String getMessage();
// 
//     /**
//      * Gets a collection of all tags in the repository that point to this commit.
//      *
//      * @return a collection of {@link GitTag} objects (may be empty)
//      */
//     @Nonnull
//     Collection<? extends GitTag> getTags();
// 
//     /**
//      * Gets a list of the parent commits.
//      *
//      * <p>If a commit has more than one parent, the commit is a merge commit, and the second and any further
//      * parents refer to the merged branch(es).</p>
//      *
//      * @return the list of parent commits; may be empty
//      */
//     @Nonnull
//     List<? extends GitCommit> getParents();
// }
// 
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/util/io/IOBiFunction.java
// @FunctionalInterface
// public interface IOBiFunction<T, U, R> {
// 
//     /**
//      * Applies this function to the given arguments.
//      *
//      * @param t the first function argument
//      * @param u the second function argument
//      * @return the function result
//      * @throws IOException for I/O errors
//      */
//     R apply(T t, U u) throws IOException;
// 
//     /**
//      * Returns a composed function that first applies this function to
//      * its input, and then applies the {@code after} function to the result.
//      * If evaluation of either function throws an exception, it is relayed to
//      * the caller of the composed function.
//      *
//      * @param <V> the type of output of the {@code after} function, and of the
//      *           composed function
//      * @param after the function to apply after this function is applied
//      * @return a composed function that first applies this function and then
//      * applies the {@code after} function
//      * @throws NullPointerException if after is null
//      */
//     default <V> IOBiFunction<T, U, V> andThen(IOFunction<? super R, ? extends V> after) {
//         Objects.requireNonNull(after);
//         return (T t, U u) -> after.apply(apply(t, u));
//     }
// }
// 
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/util/io/IOConsumer.java
// public interface IOConsumer<T> {
// 
//     /**
//      * Performs this operation on the given argument.
//      *
//      * @param t the input argument
//      * @throws IOException for I/O errors
//      */
//     void accept(T t) throws IOException;
// 
// 
//     /**
//      * Returns a composed {@code IOConsumer} that performs, in sequence, this
//      * operation followed by the {@code after} operation. If performing either
//      * operation throws an exception, it is relayed to the caller of the
//      * composed operation.  If performing this operation throws an exception,
//      * the {@code after} operation will not be performed.
//      *
//      * @param after the operation to perform after this operation
//      * @return a composed {@code IOConsumer} that performs in sequence this
//      * operation followed by the {@code after} operation
//      * @throws NullPointerException if {@code after} is null
//      */
//     default IOConsumer<T> andThen(IOConsumer<? super T> after) {
//         Objects.requireNonNull(after);
//         return (T t) -> { accept(t); after.accept(t); };
//     }
// }
// 
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/util/io/IOFunction.java
// @FunctionalInterface
// public interface IOFunction<T, R> {
// 
//     R apply(T t) throws IOException;
// }
// 
// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/util/io/IOUtils.java
// public final class IOUtils {
// 
//     private IOUtils() { }
// 
//     public static <T> T unchecked(IOCallable<T> callable) {
//         try {
//             return callable.call();
//         } catch (IOException ex) {
//             throw new RuntimeIOException(ex);
//         }
//     }
// 
//     public static void unchecked(IORunnable runnable) {
//         try {
//             runnable.run();
//         } catch (IOException ex) {
//             throw new RuntimeIOException(ex);
//         }
//     }
// }


// Path: src/main/java/org/unbrokendome/gradle/plugins/gitversion/model/jgit/JGitWalkIterator.java
import com.google.common.collect.AbstractIterator;
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.revwalk.RevWalk;
import org.unbrokendome.gradle.plugins.gitversion.model.CloseableIterator;
import org.unbrokendome.gradle.plugins.gitversion.model.GitCommit;
import org.unbrokendome.gradle.plugins.gitversion.util.io.IOBiFunction;
import org.unbrokendome.gradle.plugins.gitversion.util.io.IOConsumer;
import org.unbrokendome.gradle.plugins.gitversion.util.io.IOFunction;
import org.unbrokendome.gradle.plugins.gitversion.util.io.IOUtils;

package org.unbrokendome.gradle.plugins.gitversion.model.jgit;



public class JGitWalkIterator extends AbstractIterator<GitCommit> implements CloseableIterator<GitCommit> {

    private final JGitRepository repository;
    private final IOFunction<RevWalk, RevCommit> firstCommitFunction;