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

net.dongliu.commons.lang.Maps Maven / Gradle / Ivy

There is a newer version: 1.0.9
Show newest version
package net.dongliu.commons.lang;

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

/**
 * utils method for map
 * 

* create map: * Map<String, Integer> map = Maps.of( * Pair.of("test", 1), * Pair.of("test2", 2), * Pair.of("test3", 3) * ); *

* * @author Dong Liu */ public class Maps { /** * get map, key-value * * @param pairs key-value list */ @SuppressWarnings("all") public static Map of(Pair... pairs) { Map map = new HashMap<>(); for (Pair pair : pairs) { map.put(pair.getKey(), pair.getValue()); } return map; } @SuppressWarnings("all") public static Map immutableOf(Pair... pairs) { return Collections.unmodifiableMap(of(pairs)); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy