// Path: src/main/java/com/verifalia/api/common/ListingCursor.java
// @Getter
// @Setter
// @ToString
// public class ListingCursor extends ListingOptions {
//     private String cursor;
// }
// 
// Path: src/main/java/com/verifalia/api/common/ListingOptions.java
// @Getter
// @SuperBuilder
// @NoArgsConstructor
// public class ListingOptions {
//     /**
//      * The maximum number of items to return with a listing request. The Verifalia API may choose to override the specified
//      * limit if it is either too small or too big. Note: a single listing operation may automatically perform different
//      * listing requests to the Verifalia API: this value limits the number of items returned by *each* API request, not
//      * the overall total number of returned items.
//      */
//     private Integer limit;
// 
//     /**
//      * The direction of the listing.
//      */
//     @Builder.Default
//     private Direction direction = Direction.Forward;
// 
//     public void setLimit(final Integer limit) {
//         if (limit != null && limit < 0) {
//             throw new IllegalArgumentException("Limit must be 0 (meaning no limit will be enforced) or greater.");
//         }
// 
//         this.limit = limit;
//     }
// 
//     public void setDirection(@NonNull final Direction direction) {
//         this.direction = direction;
//     }
// }
// 
// Path: src/main/java/com/verifalia/api/common/models/ListSegment.java
// @Getter
// @Setter
// @ToString
// public abstract class ListSegment<T> {
//     /**
//      * The meta-data for this list segment.
//      */
//     private ListSegmentMeta meta;
// 
//     /**
//      * The items of type <tt>T</tt> included in this segment.
//      */
//     private List<T> data;
// }
// 
// Path: src/main/java/com/verifalia/api/exceptions/VerifaliaException.java
// public class VerifaliaException extends Exception {
//     private RestResponse response;
// 
//     public VerifaliaException(@NonNull final RestResponse response) {
//         super(response.getStatusCode() + ": " + response.readAsString());
//         this.response = response;
//     }
// 
//     public VerifaliaException(String errorMessage) {
//         super(errorMessage);
//     }
// 
//     public VerifaliaException(String message, Throwable cause) {
//         super(message, cause);
//     }
// }


import com.verifalia.api.common.ListingCursor;
import com.verifalia.api.common.ListingOptions;
import com.verifalia.api.common.models.ListSegment;
import com.verifalia.api.exceptions.VerifaliaException;
import lombok.NonNull;
import lombok.SneakyThrows;
import java.util.Iterator;
import java.util.NoSuchElementException;
            this.segment = segment;
            this.nextSegmentFetcher = nextSegmentFetcher;
            this.options = options;
        }

        @SneakyThrows
        @Override
        public boolean hasNext() {
            fetchNextSegmentIfNeeded();

            return segment != null && (consumedInSegment < segment.getData().size());
        }

        @SneakyThrows
        @Override
        public Object next() {
            fetchNextSegmentIfNeeded();

            if (segment == null) {
                throw new NoSuchElementException();
            }

            return segment.getData().get(consumedInSegment++);
        }

        private void fetchNextSegmentIfNeeded() throws VerifaliaException {
            if (consumedInSegment >= segment.getData().size()) {
                consumedInSegment = 0;

                if (segment.getMeta() != null && segment.getMeta().getIsTruncated()) {
// Path: src/main/java/com/verifalia/api/common/ListingCursor.java
// @Getter
// @Setter
// @ToString
// public class ListingCursor extends ListingOptions {
//     private String cursor;
// }
// 
// Path: src/main/java/com/verifalia/api/common/ListingOptions.java
// @Getter
// @SuperBuilder
// @NoArgsConstructor
// public class ListingOptions {
//     /**
//      * The maximum number of items to return with a listing request. The Verifalia API may choose to override the specified
//      * limit if it is either too small or too big. Note: a single listing operation may automatically perform different
//      * listing requests to the Verifalia API: this value limits the number of items returned by *each* API request, not
//      * the overall total number of returned items.
//      */
//     private Integer limit;
// 
//     /**
//      * The direction of the listing.
//      */
//     @Builder.Default
//     private Direction direction = Direction.Forward;
// 
//     public void setLimit(final Integer limit) {
//         if (limit != null && limit < 0) {
//             throw new IllegalArgumentException("Limit must be 0 (meaning no limit will be enforced) or greater.");
//         }
// 
//         this.limit = limit;
//     }
// 
//     public void setDirection(@NonNull final Direction direction) {
//         this.direction = direction;
//     }
// }
// 
// Path: src/main/java/com/verifalia/api/common/models/ListSegment.java
// @Getter
// @Setter
// @ToString
// public abstract class ListSegment<T> {
//     /**
//      * The meta-data for this list segment.
//      */
//     private ListSegmentMeta meta;
// 
//     /**
//      * The items of type <tt>T</tt> included in this segment.
//      */
//     private List<T> data;
// }
// 
// Path: src/main/java/com/verifalia/api/exceptions/VerifaliaException.java
// public class VerifaliaException extends Exception {
//     private RestResponse response;
// 
//     public VerifaliaException(@NonNull final RestResponse response) {
//         super(response.getStatusCode() + ": " + response.readAsString());
//         this.response = response;
//     }
// 
//     public VerifaliaException(String errorMessage) {
//         super(errorMessage);
//     }
// 
//     public VerifaliaException(String message, Throwable cause) {
//         super(message, cause);
//     }
// }


// Path: src/main/java/com/verifalia/api/common/iterables/IterableHelper.java
import com.verifalia.api.common.ListingCursor;
import com.verifalia.api.common.ListingOptions;
import com.verifalia.api.common.models.ListSegment;
import com.verifalia.api.exceptions.VerifaliaException;
import lombok.NonNull;
import lombok.SneakyThrows;
import java.util.Iterator;
import java.util.NoSuchElementException;

            this.segment = segment;
            this.nextSegmentFetcher = nextSegmentFetcher;
            this.options = options;
        }

        @SneakyThrows
        @Override
        public boolean hasNext() {
            fetchNextSegmentIfNeeded();

            return segment != null && (consumedInSegment < segment.getData().size());
        }

        @SneakyThrows
        @Override
        public Object next() {
            fetchNextSegmentIfNeeded();

            if (segment == null) {
                throw new NoSuchElementException();
            }

            return segment.getData().get(consumedInSegment++);
        }

        private void fetchNextSegmentIfNeeded() throws VerifaliaException {
            if (consumedInSegment >= segment.getData().size()) {
                consumedInSegment = 0;

                if (segment.getMeta() != null && segment.getMeta().getIsTruncated()) {
                    ListingCursor cursor = new ListingCursor();