Class StringPoolInstance


  • public class StringPoolInstance
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      StringPoolInstance​(int cacheSize)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clearPool()
      Clears the pool of strings.
      java.lang.String getFromPool​(java.lang.String value)
      The same as reuse(String) but allows to pass and return nulls.
      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

      • StringPoolInstance

        public StringPoolInstance​(int cacheSize)
    • Method Detail

      • getFromPool

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