MCPcopy Create free account
hub / github.com/antlr/codebuff / newStrongInterner

Method newStrongInterner

output/java_guava/1.4.17/Interners.java:45–54  ·  view source on GitHub ↗

Returns a new thread-safe interner which retains a strong reference to each instance it has interned, thus preventing these instances from being garbage-collected. If this retention is acceptable, this implementation may perform better than #newWeakInterner.

()

Source from the content-addressed store, hash-verified

43
44
45 public static <E> Interner<E> newStrongInterner() {
46 final ConcurrentMap<E, E> map = new MapMaker().makeMap();
47 return new Interner<E>() {
48 @Override
49 public E intern(E sample) {
50 E canonical = map.putIfAbsent(checkNotNull(sample), sample);
51 return (canonical == null) ? sample : canonical;
52 }
53 };
54 }
55
56 /**
57 * Returns a new thread-safe interner which retains a weak reference to each instance it has

Callers

nothing calls this directly

Calls 1

makeMapMethod · 0.45

Tested by

no test coverage detected