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