com.microsoft.bingads.v10.bulk.entities.BulkTargetWithLocation 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.v10.bulk.entities;
import com.microsoft.bingads.internal.functionalinterfaces.BiConsumer;
import com.microsoft.bingads.internal.functionalinterfaces.Consumer;
import com.microsoft.bingads.internal.functionalinterfaces.Function;
import com.microsoft.bingads.internal.functionalinterfaces.Supplier;
import com.microsoft.bingads.v10.campaignmanagement.LocationTarget;
import java.util.ArrayList;
import java.util.List;
/**
* This abstract base class provides properties that are shared by all bulk entities mapped to the API LocationTarget2 object.
*
* @param see {@link BulkTargetBid}
*/
abstract class BulkTargetWithLocation extends BulkSubTarget {
protected LocationTarget location;
public BulkTargetWithLocation(Class classOfTBid) {
super(classOfTBid);
}
protected void reconstructApiBids(List bulkBids,
Function createBid,
Supplier getTarget,
Supplier createNewTarget,
Consumer setTarget,
Supplier> getBids,
Consumer> setBids) {
List apiBidsFromFile = new ArrayList();
for (TBid bulkBid : bulkBids) {
apiBidsFromFile.add(createBid.apply(bulkBid));
}
if (apiBidsFromFile.isEmpty()) {
return;
}
if (getTarget.get() == null) {
setTarget.accept(createNewTarget.get());
setBids.accept(new ArrayList());
}
List targetBids = getBids.get();
for (TApiBid apiBid : apiBidsFromFile) {
targetBids.add(apiBid);
}
}
protected void convertBidsFromApi(List bids,
Supplier getTarget,
Function> getBids,
final BiConsumer setAdditionalBidProperties,
Function shouldConvertBid
) {
TTarget target = getTarget.get();
if (target == null) {
return;
}
List rawBids = getBids.apply(target);
if (rawBids == null) {
return;
}
for (final T rawBid : rawBids) {
if (shouldConvertBid.apply(rawBid)) {
TBid bid = createAndPopulateBid(new Consumer() {
@Override
public void accept(TBid t) {
setAdditionalBidProperties.accept(t, rawBid);
}
});
bids.add(bid);
}
}
}
protected T getLocationProperty(Function getFunc) {
if (getLocation() == null) {
return null;
}
return getFunc.apply(getLocation());
}
protected void setLocationProperty(Consumer setAction) {
if (getLocation() == null) {
setLocation(new LocationTarget());
}
setAction.accept(getLocation());
}
public LocationTarget getLocation() {
return location;
}
public void setLocation(LocationTarget location) {
this.location = location;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy