use of com.mxt.anitrend.model.entity.base.StaffBase in project anitrend-app by AniTrend.
the class GroupingUtil method groupStaffByLanguage.
/**
* Groups media by the media format, assuming that the media has be sorted by language
* @see KeyUtil.StaffSort
* <br/>
*
* Only to be used when the sort type is @{@link KeyUtil.StaffSort#LANGUAGE}
* which is the default sort type for the request @{@link KeyUtil#STAFF_MEDIA_REQ}
* <br/>
*
* @param edges The potential external model response which needs to be grouped
* @param model The current model item/s containing all data minus current mediaItems
*/
public static List<EntityGroup> groupStaffByLanguage(@NonNull List<StaffBase> edges, @Nullable List<EntityGroup> model) {
List<EntityGroup> entityMap = new ArrayList<>();
Map<String, List<StaffBase>> map = Stream.of(edges).filter(value -> !TextUtils.isEmpty(value.getLanguage())).collect(Collectors.groupingBy(StaffBase::getLanguage));
for (Map.Entry<String, List<StaffBase>> entry : CompatUtil.getKeyFilteredMap(map)) {
EntityHeader entityHeader = new EntityHeader(entry.getKey(), entry.getValue().size());
if (model == null || !model.contains(entityHeader))
entityMap.add(entityHeader);
entityMap.addAll(entry.getValue());
}
return entityMap;
}
Aggregations