/** * Static factory method for creating a fresh {@link MapBuilder}. * * @param <K> the key type * @param <V> the value type * @return a new empty {@link MapBuilder} */ public static <K, V> MapBuilder<K, V> newBuilder() { return new MapBuilder<K, V>(); }
/** * Static factory method for creating a fresh {@link MapBuilder} based on the contents of a source Map. * * @param <K> the key type * @param <V> the value type * @param map the source map, may be {@code null} * @return a new {@link MapBuilder}, populated with the values from {@code map}, if one is provided */ public static <K, V> MapBuilder<K, V> newBuilder(final @Nullable Map<? extends K, ? extends V> map) { return new MapBuilder<K,V>().addAll(map); }
/** * Static factory method for creating a fresh {@link MapBuilder} and adding the given key/value pair. * * @param <K> the key type * @param <V> the value type * @param key the key * @param value the value * @return a new {@link MapBuilder} */ public static <K, V> MapBuilder<K, V> newBuilder(final K key, final V value) { return new MapBuilder<K, V>().add(key, value); }
/** * Static factory method for creating a fresh {@link MapBuilder} and adding the given key/value pairs. * * @param <K> the key type * @param <V> the value type * @param key1 the key * @param value1 the value * @param key2 the key * @param value2 the value * @return a new {@link MapBuilder} with the specified elements */ public static <K, V> MapBuilder<K, V> newBuilder(final K key1, final V value1, final K key2, final V value2) { return new MapBuilder<K, V>().add(key1, value1).add(key2, value2); }
/** * Static factory method for creating a fresh {@link MapBuilder} and adding the given key/value pairs. * * @param <K> the key type * @param <V> the value type * @param key1 the key * @param value1 the value * @param key2 the key * @param value2 the value * @param key3 the key * @param value3 the value * @return a new {@link MapBuilder} with the specified elements */ public static <K, V> MapBuilder<K, V> newBuilder(final K key1, final V value1, final K key2, final V value2, final K key3, final V value3) { return new MapBuilder<K, V>().add(key1, value1).add(key2, value2).add(key3, value3); }
/** * Static factory method for creating a fresh {@link MapBuilder} and adding the given key/value pairs. * * @param <K> the key type * @param <V> the value type * @param key1 the key * @param value1 the value * @param key2 the key * @param value2 the value * @param key3 the key * @param value3 the value * @param key4 the key * @param value4 the value * @return a new {@link MapBuilder} with the specified elements */ public static <K, V> MapBuilder<K, V> newBuilder(final K key1, final V value1, final K key2, final V value2, final K key3, final V value3, final K key4, final V value4) { return new MapBuilder<K, V>().add(key1, value1).add(key2, value2).add(key3, value3).add(key4, value4); }