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

com.microsoft.bingads.v10.bulk.entities.BulkAgeTarget 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.23.2
Show newest version
package com.microsoft.bingads.v10.bulk.entities;

import com.microsoft.bingads.internal.functionalinterfaces.Consumer;
import com.microsoft.bingads.v10.campaignmanagement.AgeTarget;
import com.microsoft.bingads.v10.campaignmanagement.AgeTargetBid;
import com.microsoft.bingads.v10.campaignmanagement.ArrayOfAgeTargetBid;

import java.util.ArrayList;
import java.util.List;

/**
 * This abstract base class provides properties that are shared by all bulk age target classes.
 *
 * @param  see {@link BulkAgeTargetBid}
 */
abstract class BulkAgeTarget extends BulkSubTarget {

    private AgeTarget ageTarget;

    public BulkAgeTarget(Class classOfTBid) {
        super(classOfTBid);
    }

    /**
     * Reserved for internal use.
     */
    @Override
    void reconstructSubTargets() {
        setAgeTarget(new AgeTarget());
        
        ArrayOfAgeTargetBid bids = new ArrayOfAgeTargetBid();
        
        getAgeTarget().setBids(bids);
        
        for (TBid bid : getBids()) {
            bids.getAgeTargetBids().add(bid.getAgeTargetBid());
        }
    }

    /**
     * Reserved for internal use.
     */
    @Override
    List convertApiToBulkBids() {
        List bulkBids = new ArrayList();
        
        if (getAgeTarget() == null || getAgeTarget().getBids() == null) {
            return bulkBids;
        }
        
        for (final AgeTargetBid apiBid : getAgeTarget().getBids().getAgeTargetBids()) {
            TBid bulkBid = createAndPopulateBid(new Consumer() {
                @Override
                public void accept(TBid t) {
                    t.setAgeTargetBid(apiBid);
                }
            });
            
            bulkBids.add(bulkBid);
        }
        
        return bulkBids;
    }

    /**
     * Reserved for internal use.
     */
    @Override
    void validatePropertiesNotNull() {
        validatePropertyNotNull(getAgeTarget(), "AgeTarget");
    }

    /**
     * Reserved for internal use.
     */
    @Override
    void validateBidsNotNullOrEmpty() {
        if (getAgeTarget() != null) {
            validateListNotNullOrEmpty(getAgeTarget().getBids(), getAgeTarget().getBids().getAgeTargetBids(), "AgeTarget.Bids");
        }
    }

    /**
     * Gets a list of age ranges to target with bid adjustments.
     */
    public AgeTarget getAgeTarget() {
        return ageTarget;
    }

    /**
     * Sets a list of age ranges to target with bid adjustments.
     */
    public void setAgeTarget(AgeTarget ageTarget) {
        this.ageTarget = ageTarget;
    }
    
    
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy