com.g2forge.alexandria.java.associative.map.HMap Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ax-java Show documentation
Show all versions of ax-java Show documentation
Standard Java library and the basis of the ${alexandria.name} project.
package com.g2forge.alexandria.java.associative.map;
import java.util.Collections;
import java.util.Map;
import java.util.function.Function;
import com.g2forge.alexandria.java.marker.Helpers;
import lombok.experimental.UtilityClass;
@Helpers
@UtilityClass
public class HMap {
public static V createOrGet(Map map, K key, Function super K, ? extends V> function) {
if (map.containsKey(key)) return map.get(key);
final V retVal = function.apply(key);
map.put(key, retVal);
return retVal;
}
public static Map empty() {
return Collections.emptyMap();
}
}