class OrderConsumer implements KvCloseableIterator<Kv>, HgPageSize {

        private final OrderBroker broker;
        private final String consumerId;
        private Iterator<Kv> dataIterator;
        private long tookCount = 0;

        OrderConsumer(OrderBroker broker) {
            this.broker = broker;
            consumerId = broker.brokerId;
        }

        private Iterator<Kv> getIterator() {
            List<Kv> list = this.broker.oneMore();

            if (log.isDebugEnabled()) {
                if (list != null && list.isEmpty()) {
                    log.debug("[ANALYSIS EMPTY] [{}] , tookCount: {}", consumerId, tookCount);
                }
            }

            if (list == null || list.isEmpty()) {
                return null;
            } else {
                return list.iterator();
            }
        }

        @Override
        public void close() {
            this.broker.finish(this.tookCount);
        }

        @Override
        public long getPageSize() {
            return PAGE_SIZE;
        }

        @Override
        public boolean hasNext() {<FILL_FUNCTION_BODY>}

        @Override
        public Kv next() {
            if (this.dataIterator == null) {
                if (!this.hasNext()) {
                    throw new NoSuchElementException();
                }
            }

            if (log.isDebugEnabled()) {
                tookCount++;
                if (tookCount % 10000 == 0) {
                    log.debug("[ANALYSIS NEXT] [{}] , tookCount: {}", consumerId, tookCount);
                }
            }
            return this.dataIterator.next();
        }

    }


            if (this.dataIterator == null) {
                this.dataIterator = this.getIterator();
            } else {
                if (this.dataIterator.hasNext()) {
                    return true;
                } else {
                    this.dataIterator = this.getIterator();
                }
            }

            if (this.dataIterator == null) {
                if (log.isDebugEnabled()) {
                    log.debug("[ANALYSIS NULL -> FALSE] [{}] , tookCount: {}", consumerId,
                              tookCount);
                }
                return false;
            } else {
                if (log.isDebugEnabled()) {
                    if (!this.dataIterator.hasNext()) {
                        log.debug("[ANALYSIS hasNext -> FALSE] [{}] , tookCount: {}", consumerId,
                                  tookCount);
                    }
                }
                return this.dataIterator.hasNext();
            }

        
<no_super_class>