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

io.magentys.cinnamon.converter.CollectionsToMapConverter Maven / Gradle / Ivy

There is a newer version: 0.2.0
Show newest version
package io.magentys.cinnamon.converter;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class CollectionsToMapConverter {

    public Map convert(final List keys, final List values) {

        if (keys == null || values == null || keys.size() != values.size()) {
            throw new IllegalArgumentException(String.format("Keys and values must be non null and the same size: keys:%s, values:%s", keys, values));
        }

        final Map converted = new HashMap<>();

        for (int i = 0; i < keys.size(); i++) {
            final String key = keys.get(i);
            final String value = values.get(i);

            converted.put(key, value);
        }

        return converted;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy