All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.javers.common.collections.Maps Maven / Gradle / Ivy

There is a newer version: 7.6.1
Show newest version
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());
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy