// Display related keywords.
if (page.getEntries() != null && page.getEntries().length > 0) {
for (TargetingIdea targetingIdea : page.getEntries()) {
Map<AttributeType, Attribute> data = Maps.toMap(targetingIdea.getData());
StringAttribute keyword = (StringAttribute) data.get(AttributeType.KEYWORD_TEXT);
IntegerSetAttribute categories =
(IntegerSetAttribute) data.get(AttributeType.CATEGORY_PRODUCTS_AND_SERVICES);
String categoriesString = "(none)";
if (categories != null && categories.getValue() != null) {
categoriesString = Joiner.on(", ").join(Ints.asList(categories.getValue()));
}
Long averageMonthlySearches =
((LongAttribute) data.get(AttributeType.SEARCH_VOLUME))
.getValue();
System.out.println("Keyword with text '" + keyword.getValue()
+ "', and average monthly search volume '" + averageMonthlySearches
+ "' was found with categories: " + categoriesString);
}
} else {
System.out.println("No related keywords were found.");