io.cloudslang.lang.entities.utils.MapUtils Maven / Gradle / Ivy
/*******************************************************************************
* (c) Copyright 2016 Hewlett-Packard Development Company, L.P.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Apache License v2.0 which accompany this distribution.
*
* The Apache License is available at
* http://www.apache.org/licenses/LICENSE-2.0
*
*******************************************************************************/
package io.cloudslang.lang.entities.utils;
import io.cloudslang.lang.entities.bindings.values.Value;
import io.cloudslang.lang.entities.bindings.values.ValueFactory;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
/**
* @author Bonczidai Levente
* @since 3/30/2016
*/
public final class MapUtils {
private MapUtils() {
}
public static Map mergeMaps(
Map map1,
Map map2) {
Map result = new HashMap<>();
putAllIfNotEmpty(result, map1);
putAllIfNotEmpty(result, map2);
return result;
}
public static Map convertMapNonSensitiveValues(Map source) {
Map target = new HashMap<>(source.size());
for (Map.Entry entry : source.entrySet()) {
target.put(entry.getKey(), ValueFactory.create(entry.getValue()));
}
return target;
}
private static void putAllIfNotEmpty(
Map target,
Map source) {
if (org.apache.commons.collections4.MapUtils.isNotEmpty(source)) {
target.putAll(source);
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy