Selector selector = new Selector();
selector.setFields(new String[] {"CampaignId", "AdExtensionId", "Status", "DisplayText",
"DestinationUrl"});
// Filter the results for specified campaign id.
Predicate campaignPredicate = new Predicate();
campaignPredicate.setOperator(PredicateOperator.EQUALS);
campaignPredicate.setField("CampaignId");
campaignPredicate.setValues(new String[] {Long.toString(campaignId)});
// Filter the results for active campaign ad extensions. You may add
// additional filtering conditions here as required.
Predicate statusPredicate = new Predicate();
statusPredicate.setOperator(PredicateOperator.EQUALS);
statusPredicate.setField("Status");
statusPredicate.setValues(new String[] {CampaignAdExtensionStatus.ACTIVE.getValue()});
// Filter for sitelinks ad extension type.
Predicate typePredicate = new Predicate();
typePredicate.setOperator(PredicateOperator.EQUALS);
typePredicate.setField("AdExtensionType");
typePredicate.setValues(new String[] {"SITELINKS_EXTENSION"});
selector.setPredicates(new Predicate[] {campaignPredicate, statusPredicate, typePredicate});
CampaignAdExtensionPage page = campaignExtensionService.get(selector);
if (page.getEntries() != null && page.getEntries().length > 0) {