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

com.microsoft.bingads.v10.bulk.entities.BulkAgeTargetBid 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.v10.bulk.entities.BulkTargetIdentifier;
import com.microsoft.bingads.v10.campaignmanagement.AgeRange;
import com.microsoft.bingads.v10.campaignmanagement.AgeTargetBid;
import com.microsoft.bingads.v10.internal.bulk.StringTable;
import com.microsoft.bingads.v10.internal.bulk.BulkMapping;
import com.microsoft.bingads.v10.internal.bulk.MappingHelpers;
import com.microsoft.bingads.v10.internal.bulk.RowValues;
import com.microsoft.bingads.v10.internal.bulk.SimpleBulkMapping;
import com.microsoft.bingads.internal.functionalinterfaces.BiConsumer;
import com.microsoft.bingads.internal.functionalinterfaces.Function;

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

/**
 * This abstract base class provides properties that are shared by all bulk age target bid classes.
 */
abstract class BulkAgeTargetBid extends BulkTargetBid {

    private AgeTargetBid ageTargetBid;

    /**
     * Reserved for internal use.
     */
    BulkAgeTargetBid(BulkTargetIdentifier identifier) {
        super(identifier);
    }
    
    private static final List> MAPPINGS;

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

        m.add(new SimpleBulkMapping(StringTable.Target,
                new Function() {
                    @Override
                    public String apply(BulkAgeTargetBid c) {
                        return c.getAgeTargetBid().getAge().value();
                    }
                },
                new BiConsumer() {
                    @Override
                    public void accept(String v, BulkAgeTargetBid c) {
                        c.getAgeTargetBid().setAge(AgeRange.fromValue(v));
                    }
                }
        ));
        
        m.add(new SimpleBulkMapping(StringTable.BidAdjustment,
                new Function() {
                    @Override
                    public Integer apply(BulkAgeTargetBid c) {
                        return c.getAgeTargetBid().getBidAdjustment();
                    }
                },
                new BiConsumer() {
                    @Override
                    public void accept(String v, BulkAgeTargetBid c) {
                        c.getAgeTargetBid().setBidAdjustment(Integer.parseInt(v));
                    }
                }
        ));
        
        MAPPINGS = Collections.unmodifiableList(m);
    }

    @Override
    public void processMappingsFromRowValues(RowValues values) {
        setAgeTargetBid(new AgeTargetBid());
        
        super.processMappingsFromRowValues(values);
        
        MappingHelpers.convertToEntity(values, MAPPINGS, this);
    }

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

    /**
     * Gets a list of age ranges to target with bid adjustments.
     */
    public AgeTargetBid getAgeTargetBid() {
        return ageTargetBid;
    }

    /**
     * Sets a list of age ranges to target with bid adjustments.
     */
    public void setAgeTargetBid(AgeTargetBid ageTargetBid) {
        this.ageTargetBid = ageTargetBid;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy