Class StringPool
- java.lang.Object
-
- org.jacoco.core.internal.analysis.StringPool
-
public final class StringPool extends java.lang.Object
Utility to normalizeString
instances in a way that ifequals()
istrue
for two strings they will be represented the same instance. While this is exactly whatString.intern()
does, this implementation avoids VM specific side effects and is supposed to be faster, as neither native code is called nor synchronization is required for concurrent lookup.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String[]
EMPTY_ARRAY
private java.util.Map<java.lang.String,java.lang.String>
pool
-
Constructor Summary
Constructors Constructor Description StringPool()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
get(java.lang.String s)
Returns a normalized instance that is equal to the givenString
.java.lang.String[]
get(java.lang.String[] arr)
Returns a modified version of the array with all string slots normalized.
-
-
-
Method Detail
-
get
public java.lang.String get(java.lang.String s)
Returns a normalized instance that is equal to the givenString
.- Parameters:
s
- any string ornull
- Returns:
- normalized instance or
null
-
get
public java.lang.String[] get(java.lang.String[] arr)
Returns a modified version of the array with all string slots normalized. It is up to the implementation to replace strings in the array instance or return a new array instance.- Parameters:
arr
- String array ornull
- Returns:
- normalized instance or
null
-
-