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

com.star.collection.map.MapBuilder Maven / Gradle / Ivy

The newest version!
package com.star.collection.map;

import java.util.Map;

/**
 * Map创建类,build模式
 *
 * @param  泛型 键
 * @param  泛型 值
 * @author starhq
 */
public class MapBuilder {

    /**
     * 需要操作的Map
     */
    private final Map maps;

    /**
     * 构造函数
     *
     * @param maps 需要操作的Map
     */
    public MapBuilder(final Map maps) {
        this.maps = maps;
    }

    /**
     * 链式Map创建
     *
     * @param key   键
     * @param value 值
     * @return 当前对象
     */
    public MapBuilder put(final K key, final V value) {
        maps.put(key, value);
        return this;
    }

    /**
     * 链式Map创建
     *
     * @param map 合并map
     * @return 当前对象
     */
    public MapBuilder putAll(final Map map) {
        this.maps.putAll(map);
        return this;
    }

    /**
     * 创建后的map
     *
     * @return 创建后的map
     */
    public Map map() {
        return maps;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy