use of com.google.api.ads.adwords.axis.v201809.cm.FunctionOperator in project googleads-java-lib by googleads.
the class MigrateToExtensionSettings method getFeedItemIdsForCampaign.
/**
* Returns the list of feed item IDs that are used by a campaign through a given campaign feed.
*/
private static Set<Long> getFeedItemIdsForCampaign(CampaignFeed campaignFeed) throws RemoteException {
Set<Long> feedItemIds = Sets.newHashSet();
FunctionOperator functionOperator = campaignFeed.getMatchingFunction().getOperator();
if (FunctionOperator.IN.equals(functionOperator)) {
// Check if matchingFunction is of the form IN(FEED_ITEM_ID,{xxx,xxx}).
// Extract feed items if applicable.
feedItemIds.addAll(getFeedItemIdsFromArgument(campaignFeed.getMatchingFunction()));
} else if (FunctionOperator.AND.equals(functionOperator)) {
// Check if matchingFunction is of the form IN(FEED_ITEM_ID,{xxx,xxx}).
// Extract feed items if applicable.
Arrays.stream(campaignFeed.getMatchingFunction().getLhsOperand()).filter(FunctionOperand.class::isInstance).map(argument -> (FunctionOperand) argument).filter(operand -> FunctionOperator.IN.equals(operand.getValue().getOperator())).forEach(operand -> feedItemIds.addAll(getFeedItemIdsFromArgument(operand.getValue())));
} else {
// There are no other matching functions involving feed item IDs.
}
return feedItemIds;
}
Aggregations