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

overflowdb.util.StringInterner Maven / Gradle / Ivy

package overflowdb.util;

import java.util.concurrent.ConcurrentHashMap;

public class StringInterner {
  private ConcurrentHashMap internedStrings = new ConcurrentHashMap<>();

  public String intern(String s){
    String interned = internedStrings.putIfAbsent(s, s);
    return interned == null ? s : interned;
  }

  public void clear() {
    internedStrings.clear();
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy