com.microsoft.bingads.v13.bulk.entities.BulkNegativeKeyword 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.campaignmanagement.MatchType;
import com.microsoft.bingads.v13.campaignmanagement.NegativeKeyword;
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;
/**
* This abstract base class for all bulk negative keywords that
* are either assigned individually to a campaign or ad group entity,
* or shared in a negative keyword list.
*
* @see BulkAdGroupNegativeKeyword
* @see BulkCampaignNegativeKeyword
* @see BulkSharedNegativeKeyword
*/
abstract class BulkNegativeKeyword extends SingleRecordBulkEntity {
private NegativeKeyword negativeKeyword;
private Status status;
private Long parentId;
private static final List> MAPPINGS;
static {
List> m = new ArrayList>();
m.add(new SimpleBulkMapping(StringTable.Id,
new Function() {
@Override
public Long apply(BulkNegativeKeyword c) {
return c.getNegativeKeyword().getId();
}
},
new BiConsumer() {
@Override
public void accept(String v, BulkNegativeKeyword c) {
c.getNegativeKeyword().setId(StringExtensions.parseOptional(v, new Function() {
@Override
public Long apply(String value) {
return Long.parseLong(value);
}
}));
}
}
));
m.add(new SimpleBulkMapping(StringTable.Status,
new Function() {
@Override
public String apply(BulkNegativeKeyword c) {
return c.getStatus() != null ? c.getStatus().value() : null;
}
},
new BiConsumer() {
@Override
public void accept(String v, BulkNegativeKeyword c) {
c.setStatus(StringExtensions.parseOptional(v, new Function() {
@Override
public Status apply(String value) {
return StringExtensions.fromValueOptional(value, Status.class);
}
}));
}
}
));
m.add(new SimpleBulkMapping(StringTable.ParentId,
new Function() {
@Override
public Long apply(BulkNegativeKeyword c) {
return c.getParentId();
}
},
new BiConsumer() {
@Override
public void accept(String v, BulkNegativeKeyword c) {
c.setParentId(StringExtensions.parseOptional(v, new Function() {
@Override
public Long apply(String value) {
return Long.parseLong(value);
}
}));
}
}
));
m.add(new SimpleBulkMapping(StringTable.Keyword,
new Function() {
@Override
public String apply(BulkNegativeKeyword c) {
return c.getNegativeKeyword().getText();
}
},
new BiConsumer() {
@Override
public void accept(String v, BulkNegativeKeyword c) {
c.getNegativeKeyword().setText(v);
}
}
));
m.add(new SimpleBulkMapping(StringTable.MatchType,
new Function() {
@Override
public String apply(BulkNegativeKeyword c) {
return StringExtensions.toMatchTypeBulkString(c.getNegativeKeyword().getMatchType());
}
},
new BiConsumer() {
@Override
public void accept(String v, BulkNegativeKeyword c) {
c.getNegativeKeyword().setMatchType(StringExtensions.parseOptional(v, new Function() {
@Override
public MatchType apply(String t) {
return StringExtensions.fromValueOptional(t, MatchType.class);
}
}));
}
}
));
MAPPINGS = Collections.unmodifiableList(m);
}
/**
* Gets a negative keyword with match type.
*/
public NegativeKeyword getNegativeKeyword() {
return negativeKeyword;
}
/**
* Sets a negative keyword with match type.
*/
public void setNegativeKeyword(NegativeKeyword negativeKeyword) {
this.negativeKeyword = negativeKeyword;
}
/**
* Gets the status of the negative keyword association.
*
*
* The value is Active if the negative keyword is assigned to the parent entity.
* The value is Deleted if the negative keyword is removed from the parent entity,
* or should be removed in a subsequent upload operation.
* Corresponds to the 'Status' field in the bulk file.
*
*/
public Status getStatus() {
return status;
}
/**
* Sets the status of the negative keyword association.
*
*
* The value is Active if the negative keyword is assigned to the parent entity.
* The value is Deleted if the negative keyword is removed from the parent entity,
* or should be removed in a subsequent upload operation.
* Corresponds to the 'Status' field in the bulk file.
*
*/
public void setStatus(Status status) {
this.status = status;
}
/**
* Reserved for internal use.
*/
Long getParentId() {
return parentId;
}
/**
* Reserved for internal use.
*/
void setParentId(Long parentId) {
this.parentId = parentId;
}
@Override
public void processMappingsFromRowValues(RowValues values) {
this.negativeKeyword = new NegativeKeyword();
this.negativeKeyword.setType("NegativeKeyword");
MappingHelpers.convertToEntity(values, MAPPINGS, this);
}
@Override
public void processMappingsToRowValues(RowValues values, boolean excludeReadonlyData) {
validatePropertyNotNull(getNegativeKeyword(), "NegativeKeyword");
MappingHelpers.convertToValues(this, values, MAPPINGS);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy