T - The type to internpublic interface Interner<T>
String.intern() but generic and multi-instance capable.
The use case for an Interner is to save memory and reduce garbage collection work. Recommended use is on
deserialization of common objects from DB, Cache or REST-Interfaces.
Example: Memory and GC calculation for short strings: A locale code like "EN" can be estimated to 56
byte:
| Modifier and Type | Method and Description |
|---|---|
T |
get(T value)
Returns a shared instance for the given value.
|
T get(T value)
String.intern(), if it is not found. Identity is determined in an implementation specific way,
which is documented by the implementation.
Further calls with the same value will typically return the interned value, but this interface does not mandate that the same shared instance is returned under under all circumstances. The implementing class should clearly document exemptions. Typical reasons are values that are only stored for a limited lifetime, or tradeoffs during concurrent writes for the sake of speed.
Implementations must be thread-safe.
value - The value to internCopyright © 2018 trivago. All rights reserved.