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

com.g2forge.alexandria.java.associative.map.HMap Maven / Gradle / Ivy

There is a newer version: 0.0.18
Show newest version
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 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();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy