Class StringUtil.StringJoiner

  • Enclosing class:
    StringUtil

    public static class StringUtil.StringJoiner
    extends java.lang.Object
    A StringJoiner allows incremental / filtered joining of a set of stringable objects.
    Since:
    1.14.1
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) boolean first  
      (package private) java.lang.StringBuilder sb  
      (package private) java.lang.String separator  
    • Constructor Summary

      Constructors 
      Constructor Description
      StringJoiner​(java.lang.String separator)
      Create a new joiner, that uses the specified separator.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      StringUtil.StringJoiner add​(java.lang.Object stringy)
      Add another item to the joiner, will be separated
      StringUtil.StringJoiner append​(java.lang.Object stringy)
      Append content to the current item; not separated
      java.lang.String complete()
      Return the joined string, and release the builder back to the pool.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • sb

        java.lang.StringBuilder sb
      • separator

        final java.lang.String separator
      • first

        boolean first
    • Constructor Detail

      • StringJoiner

        public StringJoiner​(java.lang.String separator)
        Create a new joiner, that uses the specified separator. MUST call complete() or will leak a thread local string builder.
        Parameters:
        separator - the token to insert between strings
    • Method Detail

      • add

        public StringUtil.StringJoiner add​(java.lang.Object stringy)
        Add another item to the joiner, will be separated
      • append

        public StringUtil.StringJoiner append​(java.lang.Object stringy)
        Append content to the current item; not separated
      • complete

        public java.lang.String complete()
        Return the joined string, and release the builder back to the pool. This joiner cannot be reused.