overflowdb.util.StringInterner Maven / Gradle / Ivy
package overflowdb.util;
import java.util.concurrent.ConcurrentHashMap;
public class StringInterner {
private static ConcurrentHashMap internedStrings = new ConcurrentHashMap<>();
public static String intern(String s){
String interned = internedStrings.putIfAbsent(s, s);
return interned == null ? s : interned;
}
}