com.microsoft.bingads.v13.bulk.entities.BulkLabel 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.Label;
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 label that can be read or written in a bulk file.
*
*
* For more information, see Label at
* https://go.microsoft.com/fwlink/?linkid=846127.
*
*
* @see BulkServiceManager
* @see BulkOperation
* @see BulkFileReader
* @see BulkFileWriter
*/
public class BulkLabel extends SingleRecordBulkEntity {
private Label label;
private Status status;
private static final List> MAPPINGS;
static {
List> m = new ArrayList>();
m.add(new SimpleBulkMapping(StringTable.Id,
new Function() {
@Override
public Long apply(BulkLabel c) {
return c.getLabel().getId();
}
},
new BiConsumer() {
@Override
public void accept(String v, BulkLabel c) {
c.getLabel().setId(StringExtensions.nullOrLong(v));
}
}
));
m.add(new SimpleBulkMapping(StringTable.Status,
new Function() {
@Override
public String apply(BulkLabel c) {
return c.getStatus() != null ? c.getStatus().value() : null;
}
},
new BiConsumer() {
@Override
public void accept(String v, BulkLabel 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.ColorCode,
new Function() {
@Override
public String apply(BulkLabel c) {
return c.getLabel().getColorCode();
}
},
new BiConsumer() {
@Override
public void accept(String v, BulkLabel c) {
c.getLabel().setColorCode(v);
}
}
));
m.add(new SimpleBulkMapping(StringTable.Description,
new Function() {
@Override
public String apply(BulkLabel c) {
return c.getLabel().getDescription();
}
},
new BiConsumer() {
@Override
public void accept(String v, BulkLabel c) {
c.getLabel().setDescription(v);
}
}
));
m.add(new SimpleBulkMapping(StringTable.Label,
new Function() {
@Override
public String apply(BulkLabel c) {
return c.getLabel().getName();
}
},
new BiConsumer() {
@Override
public void accept(String v, BulkLabel c) {
c.getLabel().setName(v);
}
}
));
MAPPINGS = Collections.unmodifiableList(m);
}
public Label getLabel() {
return label;
}
public void setLabel(Label label) {
this.label = label;
}
public Status getStatus() {
return status;
}
public void setStatus(Status status) {
this.status = status;
}
@Override
public void processMappingsFromRowValues(RowValues values) {
this.setLabel(new Label());
MappingHelpers.convertToEntity(values, MAPPINGS, this);
}
@Override
public void processMappingsToRowValues(RowValues values, boolean excludeReadonlyData) {
validatePropertyNotNull(getLabel(), "Label");
MappingHelpers.convertToValues(this, values, MAPPINGS);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy