org.javers.guava.Multimaps Maven / Gradle / Ivy
package org.javers.guava;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.ForwardingMultimap;
import com.google.common.collect.Multimap;
import org.javers.common.collections.Sets;
import java.util.Collections;
import java.util.Set;
/**
* @author akrystian
*/
class Multimaps{
/**
* null args are allowed
*/
public static Set commonKeys(Multimap left, Multimap right){
if (left == null || right == null) {
return Collections.emptySet();
}
return Sets.intersection(left.keySet(), right.keySet());
}
/**
* null args are allowed
*/
public static Set keysDifference(Multimap left, Multimap right){
if (left == null){
return Collections.emptySet();
}
if (right == null){
return left.keySet();
}
return Sets.difference(left.keySet(), right.keySet());
}
public static Multimap toNotNullMultimap(Object sourceMap){
if (sourceMap == null){
return ArrayListMultimap.create();
}else{
return (Multimap) sourceMap;
}
}
}