net.amygdalum.util.builders.Maps Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of compilerutils Show documentation
Show all versions of compilerutils Show documentation
Utility classes needed for search and compiler applications
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