集册 Java实例教程 获取对键集中提供的每个键都具有空值的映射。

获取对键集中提供的每个键都具有空值的映射。

欢马劈雪     最近更新时间:2020-01-02 10:19:05

398
获取对键集中提供的每个键都具有空值的映射。

/*

 * Copyright Terracotta, Inc.

 *

 * Licensed under the Apache License, Version 2.0 (the "License");

 * you may not use this file except in compliance with the License.

 * You may obtain a copy of the License at

 *

 *     http://www.apache.org/licenses/LICENSE-2.0

 *

 * Unless required by applicable law or agreed to in writing, software

 * distributed under the License is distributed on an "AS IS" BASIS,

 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

 * See the License for the specific language governing permissions and

 * limitations under the License.

 */

//package com.nowjava;

import java.util.ArrayList;
/*
来 自*
 时 代 J a v a 公 众 号
*/


import java.util.Collections;


import java.util.LinkedHashMap;


import java.util.List;

import java.util.Map;


public class Main {

    /**

     * Gets a {@code Map} having a {@code null} value for each of the keys provided in {@code keySet}.

     *

     * @param keySet the {@code Iterable} over the keys for the result {@code Map}

     *

     * @return a new, insert-ordered, modifiable {@code Map} holding {@code null} values for each key provided

     */

    static Map<String, String> getNullEntryMap(final Iterable<String> keySet) {

        return getNullEntryMap(Collections.singletonList(keySet));

    }
/*时 代 J     a    v  a - nowjava.com*/

    /**

     * Gets a {@code Map} having a {@code null} value for each of the keys provided all identified keySets.

     *

     * @param keySet1 the first {@code Iterable} over the keys for the result {@code Map}

     * @param keySet2 the second {@code Iterable} over the keys for the result {@code Map}

     *

     * @return a new, insert-ordered, modifiable {@code Map} holding {@code null} values for each key provided

     */

    static Map<String, String> getNullEntryMap(

            final Iterable<String> keySet1, final Iterable<String> keySet2) {

        final List<Iterable<String>> keySets = new ArrayList<Iterable<String>>(

                2);

        keySets.add(keySet1);

        keySets.add(keySet2);

        return getNullEntryMap(keySets);

    }


    /**

     * Gets a {@code Map} having a {@code null} value for each of the keys provided in {@code keySets}.

     *

     * @param keySets the {@code Iterable}s over the keys for the result {@code Map}

     *

     * @return a new, insert-ordered, modifiable {@code Map} holding {@code null} values for each key provided

     */

    private static Map<String, String> getNullEntryMap(

            final 
展开阅读全文