placementAdGroupCriterionOperation.setOperator(Operator.ADD);
operations.add(placementAdGroupCriterionOperation);
}
// Add ad group criteria.
AdGroupCriterionReturnValue result =
adGroupCriterionService.mutate(operations.toArray(new AdGroupCriterionOperation[] {}));
// Display results.
for (AdGroupCriterion adGroupCriterionResult : result.getValue()) {
if (adGroupCriterionResult.getCriterion() != null) {
System.out.printf("Ad group criterion with ad group id '%d', and criterion id '%d', "
+ "and placement '%s' was added.\n", adGroupCriterionResult.getAdGroupId(),
adGroupCriterionResult.getCriterion().getId(),
((Placement) adGroupCriterionResult.getCriterion()).getUrl());
}
}
for (ApiError apiError : result.getPartialFailureErrors()) {
Matcher matcher = operationIndexPattern.matcher(apiError.getFieldPath());
if (matcher.matches()) {
int operationIndex = Integer.parseInt(matcher.group(1));
AdGroupCriterion adGroupCriterion = operations.get(operationIndex).getOperand();
System.out.printf("Ad group criterion with ad group id '%d' and placement '%s' "