SearchMetadata metadata = new SearchMetadata();
metadata.setFacets(new ToneFacetArray());
for(Map.Entry<Tone, Integer> entry : toneCounts.entrySet())
{
ToneFacet f = new ToneFacet();
f.setTone(entry.getKey());
f.setCount(entry.getValue());
metadata.getFacets().add(f);
}
return new CollectionResult<Greeting, SearchMetadata>(greetings, null, metadata);
}