Search in sources :

Example 1 with ICacheEntryFilter

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;
}
Also used : ICacheEntryFilter(org.eclipse.scout.rt.shared.cache.ICacheEntryFilter) HashMap(java.util.HashMap) InvalidateCacheNotification(org.eclipse.scout.rt.shared.cache.InvalidateCacheNotification) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList)

Aggregations

ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 ICacheEntryFilter (org.eclipse.scout.rt.shared.cache.ICacheEntryFilter)1 InvalidateCacheNotification (org.eclipse.scout.rt.shared.cache.InvalidateCacheNotification)1