package com.ssyf.common.core.util;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * @author: huwei
 * @date: 2020/6/3 10:47
 * @version: 1.0.0
 */
public class MapUtil {

    public static <K, V> MapBuilder builder() {
        return new MapBuilder<K, V>();
    }



    public static class MapBuilder<K, V> {
        Map<K, V> map;

        {
            this.map = new LinkedHashMap<>();
        }

        public MapBuilder elem(K key, V value) {
            this.map.put(key, value);
            return this;
        }

        public MapBuilder elem(Map<K, V> more) {
            this.map.putAll(more);
            return this;
        }

        public MapBuilder put(K key, V value) {
            this.map.put(key, value);
            return this;
        }

        public MapBuilder putAll(Map<K, V> more) {
            this.map.putAll(more);
            return this;
        }

        public Map<K, V> build() {
            return map;
        }
    }
}
