jetbrains.buildServer.util
Class StringPool

java.lang.Object
  extended by jetbrains.buildServer.util.StringPool

public class StringPool
extends java.lang.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
StringPool()
           
 
Method Summary
static void clearPool()
          Clears the pool of strings.
static java.lang.String getFromPool(java.lang.String value)
          The same as reuse(String) but allows to pass and return nulls.
static java.lang.String reuse(java.lang.String value)
          Ensures that the string is reused.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StringPool

public StringPool()
Method Detail

getFromPool

public static java.lang.String getFromPool(@Nullable
                                           java.lang.String value)
The same as reuse(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 java.lang.String reuse(@NotNull
                                             java.lang.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.