org.javers.common.collections.Maps Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of javers-core Show documentation
Show all versions of javers-core Show documentation
JaVers - object auditing and diff framework for Java
package org.javers.common.collections;
import java.util.Collections;
import java.util.Map;
import java.util.Set;
/**
* @author bartosz walacik
*/
public class Maps {
public static Map wrapNull(Object map){
if (map == null){
return Collections.emptyMap();
}
return (Map)map;
}
/**
* null args are allowed
*/
public static Set commonKeys(Map left, Map right) {
if (left == null || right == null) {
return Collections.emptySet();
}
return Sets.intersection(left.keySet(),right.keySet());
}
/**
* null args are allowed
*/
public static Set keysDifference(Map left, Map right) {
if (left == null){
return Collections.emptySet();
}
if (right == null){
return left.keySet();
}
return Sets.difference(left.keySet(), right.keySet());
}
}