/* * (non-Javadoc) * * @see org.hamster.core.api.util.difference.walker.Walker#walkForAdded(java.util.Map, java.util.Collection) */ @Override public Collection<T> walkForAdded( Map<K, T> sourceMap, Collection<T> targetColl, Map<String, Method> methods) { List<T> result = Lists.newArrayList(); for (T target : targetColl) { K id = idInvoker.invoke(methods, target); if (id == null || !sourceMap.containsKey(id)) { result.add(target); } } return result; }
/* * (non-Javadoc) * * @see org.hamster.core.api.util.difference.walker.Walker#walkForRemoved(java.util.Map, java.util.Collection) */ @Override public Map<K, T> walkForRemoved( Map<K, T> sourceMap, Collection<T> targetColl, Map<String, Method> methods) { Map<K, T> result = Maps.newHashMap(); Set<K> keys = Sets.newHashSet(); for (T target : targetColl) { K id = idInvoker.invoke(methods, target); keys.add(id); } for (Map.Entry<K, T> sourceEntry : sourceMap.entrySet()) { if (!keys.contains(sourceEntry.getKey())) { result.put(sourceEntry.getKey(), sourceEntry.getValue()); } } return result; }