Here you can find the source of map(final Entry
Parameter | Description |
---|---|
entries | the <i>final</i> set of entries to add to the newly created <i>unmodifiable</i> map |
public static <K, V> Map<K, V> map(final Entry<K, V>... entries)
//package com.java2s; /*//from w w w . ja v a 2 s. co m * Copyright (C) 2013 * * 52?North Initiative for Geospatial Open Source Software GmbH * Contact: Andreas Wytzisk * Martin-Luther-King-Weg 24 * 48155 Muenster, Germany * info@52north.org * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ import java.util.Collections; import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; public class Main { /** * @param entries the <i>final</i> set of entries to add to the newly created <i>unmodifiable</i> map * @return an <i>unmodifiable</i> map with all given entries */ public static <K, V> Map<K, V> map(final Entry<K, V>... entries) { final HashMap<K, V> map = new HashMap<K, V>(entries.length); for (final Entry<K, V> entry : entries) { map.put(entry.getKey(), entry.getValue()); } return Collections.unmodifiableMap(map); } public static <K, V> Map<K, V> map() { return new HashMap<K, V>(); } /** * @return an <b>UNMODIFIABLE</b> Map<K, V> */ public static <K, V> Map<K, V> unmodifiableMap(final Map<? extends K, ? extends V> m) { return (m == null) ? Collections.<K, V>emptyMap() : Collections.unmodifiableMap(m); } }