com.microsoft.bingads.v13.internal.bulk.DynamicColumnNameMapping Maven / Gradle / Ivy
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);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy