Thanks for the suggestion Jason.  The code example does it slightly 
differently: 
https://code.google.com/p/google-api-ads-java/source/browse/examples/adwords_axis/src/main/java/adwords/axis/v201209/reporting/DownloadCriteriaReport.java#64

That link unfortunately won't work - the latest version of the 
ReportDefinitionService doesn't define the Selector class anymore.  Did you 
follow a link to this page?  We should fix that if so.

- Kevin Winter
AdWords API Team

On Thursday, September 27, 2012 7:58:05 AM UTC-4, Jason Stedman wrote:
>
> Christian,
>
> This is more a java suggestion than anything to do with AdWords as your 
> posted code works, but I think it is aligned with the nature of the 
> question.
>
> A cleaner way to handle this would be to extract the array of strings out 
> of the constructor calls and setter methods and instead make them fields of 
> your class. This also saves on garbage collection overhead if you make 
> multiple calls to that method reusing the same instance of your class. I 
> feel this will also make the code much more maintainable in the future.
>
> You can then abstract the logic out to something like this(which addAll 
> most likely does anyway under the covers):
>
> {
> // class level declarations to save on garbage collection for things that 
> are always initialized with the same value in a particular method
> String[] fieldsInReport = new String[] {"AdGroupId", "KeywordId", "Id", 
> "Impressions", "Clicks", "Cost", "AveragePosition", "Date"};
> String[] predicateValues = new String[] {"ENABLED", "PAUSED", "DISABLED"};
> ...
>
> // inside the method which uses the arrays of Strings
>     for(String field : fieldsInReport){
>         fields.add(field);
>     }
>     statusPredicate = new Predicate();
>     statusPredicate.setField("Status");
>     statusPredicate.setOperator(PredicateOperator.IN);
>     List<String> values = statusPredicate.getValues();
>     for(String value : predicateValues){
>         values.add(value);
>     }
> }
>
> AdWords team : While thinking about this question I noticed the 
> documentation is broken for the new Selector class in 
> ReportDefinitionService:
>
>
> https://developers.google.com/adwords/api/docs/reference/latest/ReportDefinitionService.Selector
>

-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
http://adwordsapi.blogspot.com
http://groups.google.com/group/adwords-api
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API Forum" group.
To post to this group, send email to adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en

Reply via email to