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

aQute.libg.map.BuilderMap Maven / Gradle / Ivy

The newest version!
package aQute.libg.map;

import java.util.HashMap;
import java.util.Map;

/**
 * A map that is to set inline like a builder. I.e. you can do `new
 * LiteralMap<>().set("a", a).set("b",b)`.
 *
 * @param  the key type
 * @param  the value type
 */
public class BuilderMap extends HashMap {
	private static final long serialVersionUID = 1L;

	public BuilderMap set(K key, V value) {
		put(key, value);
		return this;
	}

	public BuilderMap setAll(Map src) {
		putAll(src);
		return this;
	}

	public BuilderMap setIfAbsent(K key, V value) {
		putIfAbsent(key, value);
		return this;
	}

	public static  BuilderMap map(K key, V value) {
		return new BuilderMap().set(key, value);
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy