All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.microsoft.bingads.v13.internal.bulk.ExtractChildEntitiesIterator Maven / Gradle / Ivy

Go to download

The Bing Ads Java SDK is a library improving developer experience when working with the Bing Ads services by providing high-level access to features such as Bulk API, OAuth Authorization and SOAP API.

There is a newer version: 13.0.22.1
Show newest version
package com.microsoft.bingads.v13.internal.bulk;

import java.util.Iterator;

import com.microsoft.bingads.v13.bulk.entities.BulkEntity;

public class ExtractChildEntitiesIterator implements Iterator {

    private Iterator children;
    private Iterator currentChildIterator;

    public ExtractChildEntitiesIterator(Iterator children) {
        this.children = children;
    }

    @Override
    public boolean hasNext() {
        this.update();

        if (this.currentChildIterator == null) {
            return false;
        }
        
        return this.currentChildIterator.hasNext() ? true : this.hasNext();
    }

    @Override
    public BulkEntity next() {
        this.update();

        if (this.currentChildIterator.hasNext()) {
            return this.currentChildIterator.next();
        }

        throw new UnsupportedOperationException();
    }

    public void update() {
        if (currentChildIterator == null || !currentChildIterator.hasNext()) {
            if (children.hasNext()) {
                BulkEntity nextChild = children.next();
                currentChildIterator = EntityExtractor.extractChildEntitiesIfNeeded(nextChild);
            } else {
                currentChildIterator = null;
            }
        }
    }

    @Override
    public void remove() {
        throw new UnsupportedOperationException("Not supported yet.");
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy