@Override
        public boolean hasNext() {
            try {
                if (this.it != null && this.it.hasNext()) {
                    return true;
                }
                else {
                    if (this.partition == null) {
                        if (this.partitions.isEmpty()) {
                            return false;
                        }
                        else {
                            this.nextPartition();
                        }
                    }
                    while (this.partition != null) {
                        // increase offset for this partition if it is not null.
                        if (this.it != null) {
                            this.offset += this.it.getOffset();
                        }
                        this.it =
                                MetaTopicBrowser.this.consumer.get(MetaTopicBrowser.this.topic, this.partition,
                                    this.offset, MetaTopicBrowser.this.maxSize, MetaTopicBrowser.this.timeoutInMills,
                                    TimeUnit.MILLISECONDS);
                        if (this.it != null && this.it.hasNext()) {
                            // If this partition still has messages, returns
                            // true.
                            return true;
                        }
                        else {
                            // move on to next partition.
                            if (this.partitions.isEmpty()) {
                                this.partition = null;
                                // There is no more partitions,return false.
                                return false;
                            }
                            else {
                                // Change partition,and continue trying to get
                                // iterator.
                                this.nextPartition();
                            }
                        }
                    }
                    return false;

                }
            }
            catch (InterruptedException e) {
                Thread.currentThread().interrupt();
                return false;
            }
            catch (Exception e) {
                throw new IllegalStateException(e);
            }

        }
TopicBrowser implementation.

@author dennis<killme2008@gmail.com>
@since 1.4.5
metamorphosis-client/src/main/java/com/taobao/metamorphosis/client/MetaTopicBrowser.java