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

com.microsoft.bingads.v13.bulk.entities.BulkExperiment 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.text.ParseException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import com.microsoft.bingads.internal.UncheckedParseException;
import com.microsoft.bingads.internal.functionalinterfaces.BiConsumer;
import com.microsoft.bingads.internal.functionalinterfaces.Function;
import com.microsoft.bingads.v13.bulk.BulkFileReader;
import com.microsoft.bingads.v13.bulk.BulkFileWriter;
import com.microsoft.bingads.v13.bulk.BulkOperation;
import com.microsoft.bingads.v13.bulk.BulkServiceManager;
import com.microsoft.bingads.v13.campaignmanagement.Experiment;
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;
import com.microsoft.bingads.v13.internal.bulk.entities.SingleRecordBulkEntity;

/**
 * Represents an experiment that can be read or written in a bulk file.
 *
 * 

* Properties of this class and of classes that it is derived from, correspond * to fields of the Experiment record in a bulk file. For more information, see * Experiment at https://go.microsoft.com/fwlink/?linkid=846127. *

* * @see BulkServiceManager * @see BulkOperation * @see BulkFileReader * @see BulkFileWriter */ public class BulkExperiment extends SingleRecordBulkEntity { private Experiment experiment; private static final List> MAPPINGS; static { List> m = new ArrayList>(); m.add(new SimpleBulkMapping(StringTable.Id, new Function() { @Override public Long apply(BulkExperiment t) { return t.getExperiment().getId(); } }, new BiConsumer() { @Override public void accept(String v, BulkExperiment c) { c.getExperiment().setId(StringExtensions.nullOrLong(v)); } })); m.add(new SimpleBulkMapping(StringTable.Status, new Function() { @Override public String apply(BulkExperiment t) { return t.getExperiment().getExperimentStatus(); } }, new BiConsumer() { @Override public void accept(String v, BulkExperiment c) { c.getExperiment().setExperimentStatus(v); } })); m.add(new SimpleBulkMapping(StringTable.Name, new Function() { @Override public String apply(BulkExperiment t) { return t.getExperiment().getName(); } }, new BiConsumer() { @Override public void accept(String v, BulkExperiment c) { c.getExperiment().setName(v); } })); m.add(new SimpleBulkMapping(StringTable.TrafficSplitPercent, new Function() { @Override public String apply(BulkExperiment t) { return StringExtensions.toBulkString(t.getExperiment().getTrafficSplitPercent()); } }, new BiConsumer() { @Override public void accept(String v, BulkExperiment c) { c.getExperiment().setTrafficSplitPercent(StringExtensions.parseOptionalInteger(v)); } })); m.add(new SimpleBulkMapping(StringTable.BaseCampaignId, new Function() { @Override public String apply(BulkExperiment t) { return StringExtensions.toBulkString(t.getExperiment().getBaseCampaignId()); } }, new BiConsumer() { @Override public void accept(String v, BulkExperiment c) { c.getExperiment().setBaseCampaignId( StringExtensions.parseOptional(v, new Function() { @Override public Long apply(String value) { return Long.parseLong(value); } })); } })); m.add(new SimpleBulkMapping(StringTable.ExperimentCampaignId, new Function() { @Override public String apply(BulkExperiment t) { return StringExtensions.toBulkString(t.getExperiment().getExperimentCampaignId()); } }, new BiConsumer() { @Override public void accept(String v, BulkExperiment c) { c.getExperiment().setExperimentCampaignId( StringExtensions.parseOptional(v, new Function() { @Override public Long apply(String value) { return Long.parseLong(value); } })); } })); m.add(new SimpleBulkMapping(StringTable.StartDate, new Function() { @Override public String apply(BulkExperiment c) { return StringExtensions.toDateBulkString(c.getExperiment().getStartDate()); } }, new BiConsumer() { @Override public void accept(String v, BulkExperiment c) { try { c.getExperiment().setStartDate(StringExtensions.parseDate(v)); } catch (ParseException ex) { throw new UncheckedParseException(ex); } } })); m.add(new SimpleBulkMapping(StringTable.EndDate, new Function() { @Override public String apply(BulkExperiment c) { return StringExtensions.toScheduleDateBulkString(c.getExperiment().getEndDate(), c.getExperiment().getId()); } }, new BiConsumer() { @Override public void accept(String v, BulkExperiment c) { try { c.getExperiment().setEndDate(StringExtensions.parseDate(v)); } catch (ParseException ex) { throw new UncheckedParseException(ex); } } })); m.add(new SimpleBulkMapping(StringTable.ExperimentType, new Function() { @Override public String apply(BulkExperiment t) { return t.getExperiment().getExperimentType(); } }, new BiConsumer() { @Override public void accept(String v, BulkExperiment c) { c.getExperiment().setExperimentType(v); } })); MAPPINGS = Collections.unmodifiableList(m); } /** * Gets the experiment. */ public Experiment getExperiment() { return this.experiment; } /** * Sets the experiment. */ public void setExperiment(Experiment experiment) { this.experiment = experiment; } @Override public void processMappingsFromRowValues(RowValues values) { this.setExperiment(new Experiment()); MappingHelpers.convertToEntity(values, MAPPINGS, this); } @Override public void processMappingsToRowValues(RowValues values, boolean excludeReadonlyData) { validatePropertyNotNull(getExperiment(), "Experiment"); MappingHelpers.convertToValues(this, values, MAPPINGS); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy