com.microsoft.bingads.v13.bulk.entities.BulkAdGroupNegativeCriterion Maven / Gradle / Ivy
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.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.AdGroupCriterionStatus;
import com.microsoft.bingads.v13.campaignmanagement.Criterion;
import com.microsoft.bingads.v13.campaignmanagement.NegativeAdGroupCriterion;
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 a negative criterion that is assigned to an ad group. Each negative criterion can be read or written in a bulk file.
*
* @see BulkServiceManager
* @see BulkOperation
* @see BulkFileReader
* @see BulkFileWriter
*/
public abstract class BulkAdGroupNegativeCriterion extends SingleRecordBulkEntity {
private NegativeAdGroupCriterion negativeAdGroupCriterion;
private String campaignName;
private String adGroupName;
private static final List> MAPPINGS;
static {
List> m = new ArrayList>();
m.add(new SimpleBulkMapping(StringTable.Status,
new Function() {
@Override
public String apply(BulkAdGroupNegativeCriterion c) {
AdGroupCriterionStatus status = c.getNegativeAdGroupCriterion().getStatus();
return status == null ? null : status.value();
}
},
new BiConsumer() {
@Override
public void accept(String v, BulkAdGroupNegativeCriterion c) {
c.getNegativeAdGroupCriterion().setStatus(StringExtensions.parseOptional(v, new Function() {
@Override
public AdGroupCriterionStatus apply(String s) {
return StringExtensions.fromValueOptional(s, AdGroupCriterionStatus.class);
}
}));
}
}
));
m.add(new SimpleBulkMapping(StringTable.Id,
new Function() {
@Override
public Long apply(BulkAdGroupNegativeCriterion c) {
return c.getNegativeAdGroupCriterion().getId();
}
},
new BiConsumer() {
@Override
public void accept(String v, BulkAdGroupNegativeCriterion c) {
c.getNegativeAdGroupCriterion().setId(StringExtensions.parseOptional(v, new Function() {
@Override
public Long apply(String s) {
return Long.parseLong(s);
}
}));
}
}
));
m.add(new SimpleBulkMapping(StringTable.ParentId,
new Function() {
@Override
public Long apply(BulkAdGroupNegativeCriterion c) {
return c.getNegativeAdGroupCriterion().getAdGroupId();
}
},
new BiConsumer() {
@Override
public void accept(String v, BulkAdGroupNegativeCriterion c) {
c.getNegativeAdGroupCriterion().setAdGroupId(StringExtensions.parseOptional(v, new Function() {
@Override
public Long apply(String value) {
return Long.parseLong(value);
}
}));
}
}
));
m.add(new SimpleBulkMapping(StringTable.Campaign,
new Function() {
@Override
public String apply(BulkAdGroupNegativeCriterion c) {
return c.getCampaignName();
}
},
new BiConsumer() {
@Override
public void accept(String v, BulkAdGroupNegativeCriterion c) {
c.setCampaignName(v);
}
}
));
m.add(new SimpleBulkMapping(StringTable.AdGroup,
new Function() {
@Override
public String apply(BulkAdGroupNegativeCriterion c) {
return c.getAdGroupName();
}
},
new BiConsumer() {
@Override
public void accept(String v, BulkAdGroupNegativeCriterion c) {
c.setAdGroupName(v);
}
}
));
MAPPINGS = Collections.unmodifiableList(m);
}
@Override
public void processMappingsFromRowValues(RowValues values) {
NegativeAdGroupCriterion adGroupCriterion = new NegativeAdGroupCriterion();
Criterion criterion = createCriterion();
adGroupCriterion.setCriterion(criterion);
adGroupCriterion.getCriterion().setType(criterion.getClass().getSimpleName());
adGroupCriterion.setType("NegativeAdGroupCriterion");
setNegativeAdGroupCriterion(adGroupCriterion);
MappingHelpers.convertToEntity(values, MAPPINGS, this);
}
protected abstract Criterion createCriterion();
@Override
public void processMappingsToRowValues(RowValues values, boolean excludeReadonlyData) {
validatePropertyNotNull(getNegativeAdGroupCriterion(), NegativeAdGroupCriterion.class.getSimpleName());
MappingHelpers.convertToValues(this, values, MAPPINGS);
}
/**
* Gets an Ad Group Criterion.
*/
public NegativeAdGroupCriterion getNegativeAdGroupCriterion() {
return negativeAdGroupCriterion;
}
/**
* Sets an Ad Group Criterion
*/
public void setNegativeAdGroupCriterion(NegativeAdGroupCriterion negativeAdGroupCriterion) {
this.negativeAdGroupCriterion = negativeAdGroupCriterion;
}
/**
* Gets the name of the campaign.
* Corresponds to the 'Campaign' field in the bulk file.
*/
public String getCampaignName() {
return campaignName;
}
/**
* Sets the name of the ad group.
* Corresponds to the 'Ad Group' field in the bulk file.
*/
public void setAdGroupName(String adGroupName) {
this.adGroupName = adGroupName;
}
/**
* Gets the name of the ad group.
* Corresponds to the 'Ad Group' field in the bulk file.
*/
public String getAdGroupName() {
return adGroupName;
}
/**
* Sets the name of the campaign.
* Corresponds to the 'Campaign' field in the bulk file.
*/
public void setCampaignName(String campaignName) {
this.campaignName = campaignName;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy