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

net.amygdalum.util.builders.Maps Maven / Gradle / Ivy

The newest version!
package net.amygdalum.util.builders;

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

public final class Maps {

	private Map map;

	private Maps(boolean linked) {
		if (linked) {
			this.map = new LinkedHashMap();
		} else {
			this.map = new HashMap();
		}
	}

	public static  Maps linked() {
		return new Maps(true);
	}

	public static  Maps hashed() {
		return new Maps(false);
	}

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

	public static  Maps invert(Map toinvert) {
		Maps maps = new Maps(false);
		for (Map.Entry entry: toinvert.entrySet()) {
			maps.put(entry.getValue(), entry.getKey());
		}
		return maps;
	}

	public Map build() {
		return map;
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy