Package jetbrains.buildServer.util
Class StringPool
- java.lang.Object
-
- jetbrains.buildServer.util.StringPool
-
public class StringPool extends Object
Simple pool for reusable strings. The pool is static, has unlimited size and thus can only be used for strings which are often the same. The pool is thread safe.- Author:
- Pavel.Sher
-
-
Constructor Summary
Constructors Constructor Description StringPool()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
clearPool()
Clears the pool of strings.static String
getFromPool(String value)
The same asreuse(String)
but allows to pass and return nulls.static String
reuse(String value)
Ensures that the string is reused.
-
-
-
Method Detail
-
getFromPool
@Nullable @Contract("null->null;!null->!null") public static String getFromPool(@Nullable String value)
The same asreuse(String)
but allows to pass and return nulls.- Parameters:
value
- string to retrieve from pool- Returns:
- returns the specified string from the pool or stores it there if it was not pooled before.
-
reuse
@NotNull public static String reuse(@NotNull String value)
Ensures that the string is reused.- Parameters:
value
- a string to get reused instance. Nulls are not allowed.- Returns:
- the reused instance.
- Since:
- 8.0
-
clearPool
public static void clearPool()
Clears the pool of strings.
-
-