keywordAdGroupCriterionOperation.setOperator(Operator.ADD);
operations.add(keywordAdGroupCriterionOperation);
}
// 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 keyword '%s' was added.\n", adGroupCriterionResult.getAdGroupId(),
adGroupCriterionResult.getCriterion().getId(),
((Keyword) adGroupCriterionResult.getCriterion()).getText());
}
}
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 keyword '%s' "