All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.microsoft.bingads.v13.internal.bulk.DynamicColumnNameMapping Maven / Gradle / Ivy

Go to download

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.

There is a newer version: 13.0.22.1
Show newest version
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 - 2024 Weber Informatics LLC | Privacy Policy