@Override @SuppressWarnings({"unchecked", "rawtypes"}) public Notification<Map> prepareNotification(Map oldValue, final Map newValue) { // Check all the elements in the map and use StandardTypeSupport // to understand whether any needs notification. // Notification is done only if at least one element needs notification. boolean notificationNeeded = false; if (oldValue == null || (oldValue.size() != newValue.size())) { notificationNeeded = true; } int index = 0; Iterator<Map.Entry> iterator = newValue.entrySet().iterator(); while (notificationNeeded == false && iterator.hasNext()) { Entry entry = iterator.next(); Object key = entry.getKey(); if (entry.getValue() != null) { Notification itemNotification = NotificationSupport.notification(oldValue.get(key), entry.getValue()); if (itemNotification.isNotificationNeeded()) { notificationNeeded = true; } } } if (notificationNeeded) { return new Notification<>(true, (Map) Collections.unmodifiableMap(new HashMap<>(newValue))); } else { return new Notification<>(false, oldValue); } } });
@Override @SuppressWarnings({"unchecked", "rawtypes"}) public Notification<List> prepareNotification(List oldValue, final List newValue) { // Check all the elements in the list and use StandardTypeSupport // to understand whether any needs notification. // Notification is done only if at least one element needs notification. boolean notificationNeeded = false; if (oldValue == null || (oldValue.size() != newValue.size())) { notificationNeeded = true; } if (newValue.isEmpty()) { notificationNeeded = false; } int index = 0; while (notificationNeeded == false && index < newValue.size()) { if (newValue.get(index) != null) { Notification itemNotification = NotificationSupport.notification(oldValue.get(index), newValue.get(index)); if (itemNotification.isNotificationNeeded()) { notificationNeeded = true; } } index++; } if (notificationNeeded) { return new Notification<>(true, (List) Collections.unmodifiableList(new ArrayList<Object>(newValue))); } else { return new Notification<>(false, oldValue); } } });
NotificationSupport.notification(pv.getValue(), finalValue);