blob: 0e92bc6dec639f7c5a4466e5c443c8816ca3949b (
plain) (
tree)
|
|
package org.openslx.dozmod.util;
import java.util.Map;
import java.util.Map.Entry;
import org.apache.log4j.Logger;
public class MapHelper {
private static final Logger LOGGER = Logger.getLogger(MapHelper.class);
private MapHelper() {
}
public static <T> boolean hasChanged(final Map<String, T> oldMap, final Map<String, T> newMap) {
if (oldMap == null && newMap == null)
return false;
if ((oldMap == null && newMap != null) || (oldMap != null && newMap == null))
return true;
// build list of users that were added, if any return true
if (oldMap.size() != newMap.size())
return true;
// no changes in the users, lets check for changes in each users permissions
for (Entry<String, T> entry : oldMap.entrySet()) {
T current = entry.getValue();
T other = newMap.get(entry.getKey());
if (!current.equals(other))
return true;
}
// everything was the same if we are still here
return false;
}
}
|