use of org.eclipse.scout.rt.shared.cache.ICacheEntryFilter in project scout.rt by eclipse.
the class InvalidateCacheNotificationCoalescer method coalesce.
@Override
public List<InvalidateCacheNotification> coalesce(List<InvalidateCacheNotification> notifications) {
List<InvalidateCacheNotification> result = new ArrayList<>();
if (notifications.isEmpty()) {
return result;
}
Map<String, List<ICacheEntryFilter<?, ?>>> filterMap = new HashMap<>();
for (InvalidateCacheNotification notification : notifications) {
List<ICacheEntryFilter<?, ?>> list = filterMap.get(notification.getCacheId());
if (list == null) {
list = new ArrayList<>();
list.add(notification.getFilter());
} else {
coalesceFilters(list, notification.getFilter());
}
filterMap.put(notification.getCacheId(), list);
}
for (Entry<String, List<ICacheEntryFilter<?, ?>>> entry : filterMap.entrySet()) {
for (ICacheEntryFilter<?, ?> filter : entry.getValue()) {
result.add(new InvalidateCacheNotification(entry.getKey(), filter));
}
}
return result;
}
Aggregations