com.microsoft.bingads.v13.internal.bulk.DynamicColumnNameMapping Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of microsoft.bingads Show documentation
Show all versions of microsoft.bingads Show documentation
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.
package com.microsoft.bingads.v13.internal.bulk;
import com.microsoft.bingads.internal.functionalinterfaces.BiConsumer;
import com.microsoft.bingads.internal.functionalinterfaces.Function;
import com.microsoft.bingads.v13.bulk.entities.BulkEntity;
/**
* A bulk mapping which accepts a function to dynamically determine the column
* for data to be stored at based on the entity
*
* @param The type of {@link BulkEntity} that the binding is for
* @param The type of the property on the {@link BulkEntity} that is
* being managed by this mapping
*/
public class DynamicColumnNameMapping extends
SingleFieldBulkMapping {
private Function fetchColumnName;
/**
* Constructor for read only mappings
*
* @param fetchColumnName Function to determine header for data to be stored
* at
* @param csvToField Function to set the value from CSV on an object
*/
public DynamicColumnNameMapping(Function fetchColumnName,
BiConsumer csvToField) {
this(fetchColumnName, null, csvToField);
}
/**
* Constructor for mappings both directions
*
* @param fetchColumnName Function to determine header for data to be stored
* at
* @param fieldToCsv Function to get the value from an entity
* @param csvToField Function to set the value from CSV on an object
*/
public DynamicColumnNameMapping(Function fetchColumnName, Function fieldToCsv, BiConsumer csvToField) {
super(fieldToCsv, csvToField);
this.fetchColumnName = fetchColumnName;
}
@Override
public String getHeader(TEntity entity) {
return this.fetchColumnName.apply(entity);
}
}