Class StringPoolInstance


  • public class StringPoolInstance
    extends Object
    • Constructor Detail

      • StringPoolInstance

        public StringPoolInstance​(int cacheSize)
    • Method Detail

      • getFromPool

        @Nullable
        @Contract("null->null;!null->!null")
        public String getFromPool​(@Nullable
                                  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 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 void clearPool()
        Clears the pool of strings.