}
private Collection<EntityGroup> createCategoryGroups(Collection<INews> input) {
/* Default Group */
EntityGroup gDefault = new EntityGroup(Group.UNKNOWN_CATEGORY.ordinal(), GROUP_CATEGORY_ID, Group.UNKNOWN_CATEGORY.getName());
Map<String, EntityGroup> groupCache = new HashMap<String, EntityGroup>();
groupCache.put(Group.UNKNOWN_CATEGORY.getName(), gDefault);
/* Group Input */
int nextId = Group.UNKNOWN_CATEGORY.ordinal() + CATEGORY_ID_BEGIN;
for (Object object : input) {
if (object instanceof INews) {
INews news = (INews) object;
List<ICategory> categories = news.getCategories();
EntityGroup group = gDefault;
if (categories.size() > 0) {
String name = categories.get(0).getName();
if (!StringUtils.isSet(name))
name = Group.UNKNOWN_CATEGORY.getName();
group = groupCache.get(name);
if (group == null) {
group = new EntityGroup(nextId++, GROUP_CATEGORY_ID, name);
groupCache.put(name, group);
}
}
new EntityGroupItem(group, news);