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

com.structurizr.util.MapUtils Maven / Gradle / Ivy

There is a newer version: 3.1.0
Show newest version
package com.structurizr.util;

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

public final class MapUtils {

    /**
     * A helper method to create a Map from an array of Strings ("name=value").
     *
     * @param nameValuePairs    one or more "name=value" pairs
     *
     * @return  a Map
     */
    public static Map create(String... nameValuePairs) {
        Map map = new HashMap<>();

        if (nameValuePairs != null) {
            for (String nameValuePair : nameValuePairs) {
                String[] tokens = nameValuePair.split("=");
                if (tokens.length == 2) {
                    map.put(tokens[0], tokens[1]);
                }
            }
        }

        return map;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy