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

com.microsoft.bingads.v13.bulk.entities.BulkAdGroupAudienceAssociation 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.bulk.entities;

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

import com.microsoft.bingads.internal.functionalinterfaces.BiConsumer;
import com.microsoft.bingads.internal.functionalinterfaces.Function;
import com.microsoft.bingads.v13.campaignmanagement.AudienceCriterion;
import com.microsoft.bingads.v13.campaignmanagement.BiddableAdGroupCriterion;
import com.microsoft.bingads.v13.campaignmanagement.Criterion;
import com.microsoft.bingads.v13.internal.bulk.BulkMapping;
import com.microsoft.bingads.v13.internal.bulk.MappingHelpers;
import com.microsoft.bingads.v13.internal.bulk.RowValues;
import com.microsoft.bingads.v13.internal.bulk.SimpleBulkMapping;
import com.microsoft.bingads.v13.internal.bulk.StringExtensions;
import com.microsoft.bingads.v13.internal.bulk.StringTable;

/**
 * Base class for all Ad Group Audience Association subclasses that can be read
 * or written in a bulk file.
 *
 * @see BulkAdGroupCustomAudienceAssociation
 * @see BulkAdGroupInMarketAudienceAssociation
 * @see BulkAdGroupProductAudienceAssociation
 * @see BulkAdGroupRemarketingListAssociation
 * @see BulkAdGroupSimilarRemarketingListAssociation
 */
public class BulkAdGroupAudienceAssociation extends BulkAdGroupBiddableCriterion {

    private String audienceName;

    private static final List> MAPPINGS;

    static {
        List> m = new ArrayList>();

        m.add(new SimpleBulkMapping(StringTable.Audience,
                new Function() {
                    @Override
                    public String apply(BulkAdGroupAudienceAssociation c) {
                        return c.getAudienceName();
                    }
                }, new BiConsumer() {
                    @Override
                    public void accept(String v, BulkAdGroupAudienceAssociation c) {
                        c.setAudienceName(v);
                    }
                }));

        m.add(new SimpleBulkMapping(StringTable.AudienceId,
                new Function() {
                    @Override
                    public Long apply(BulkAdGroupAudienceAssociation c) {
                        if (c.getBiddableAdGroupCriterion() instanceof BiddableAdGroupCriterion) {
                            AudienceCriterion audienceCriterion = (AudienceCriterion) c.getBiddableAdGroupCriterion()
                                    .getCriterion();
                            if (audienceCriterion == null) {
                                return null;
                            } else {
                                return audienceCriterion.getAudienceId();
                            }
                        } else {
                            return null;
                        }
                    }
                }, new BiConsumer() {
                    @Override
                    public void accept(String v, BulkAdGroupAudienceAssociation c) {
                        AudienceCriterion audienceCriterion = (AudienceCriterion) c.getBiddableAdGroupCriterion()
                                .getCriterion();
                        if (audienceCriterion == null) {
                            return;
                        }

                        audienceCriterion
                                .setAudienceId(StringExtensions.parseOptional(v, new Function() {
                                    @Override
                                    public Long apply(String value) {
                                        return Long.parseLong(value);
                                    }
                                }));
                    }
                }));

        MAPPINGS = Collections.unmodifiableList(m);
    }

    @Override
    public void processMappingsFromRowValues(RowValues values) {
        super.processMappingsFromRowValues(values);
        MappingHelpers.convertToEntity(values, MAPPINGS, this);
    }
    
    @Override
    protected Criterion createCriterion() {
        return new AudienceCriterion();
    }

    @Override
    public void processMappingsToRowValues(RowValues values, boolean excludeReadonlyData) {
        super.processMappingsToRowValues(values, excludeReadonlyData);
        MappingHelpers.convertToValues(this, values, MAPPINGS);
    }

    /**
     * Gets an AdGroup Criterion.
     */
    public BiddableAdGroupCriterion getBiddableAdGroupCriterion() {
        return this.biddableAdGroupCriterion;
    }


    /**
     * Gets the name of the audience.
     */
    public String getAudienceName() {
        return this.audienceName;
    }

    /**
     * Sets the name of the audience.
     */
    public void setAudienceName(String audienceName) {
        this.audienceName = audienceName;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy