类 Joiner


  • public class Joiner
    extends java.lang.Object
    A immutable value class for joining strings. This class is immutable, and should be reused across multi invocations of join with same rule.
    • 方法概要

      所有方法 静态方法 实例方法 具体方法 
      修饰符和类型 方法 说明
      java.lang.String join​(@NonNull java.lang.Iterable<?> values)
      Join strings, with prefix, suffix, and delimiter
      java.lang.String join​(@Nullable java.lang.Object @NonNull ... values)
      Join strings, with prefix, suffix, and delimiter
      Joiner nullToEmpty()
      Return a new Joiner which treat null elements as empty str instead of "null".
      static Joiner of​(java.lang.CharSequence delimiter)
      Create new String Joiner.
      static Joiner of​(java.lang.CharSequence prefix, java.lang.CharSequence suffix, java.lang.CharSequence delimiter)
      Create new String Joiner.
      Joiner skipEmpty()
      Return a new Joiner which skip empty strings.
      Joiner skipNulls()
      Return a new Joiner with skip the null elements.
      Joiner withPrefix​(java.lang.CharSequence prefix)
      Return a new Joiner which using the given prefix for joined string result.
      Joiner withSuffix​(java.lang.CharSequence suffix)
      Return a new Joiner which using the given suffix for joined string result.
      • 从类继承的方法 java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 方法详细资料

      • of

        public static Joiner of​(java.lang.CharSequence prefix,
                                java.lang.CharSequence suffix,
                                java.lang.CharSequence delimiter)
        Create new String Joiner.
        参数:
        prefix - the prefix to prepend, can not be null
        suffix - the suffix to append, can not be null
        delimiter - the delimiter to join multi string items, can not be null
        返回:
        Joiner
      • of

        public static Joiner of​(java.lang.CharSequence delimiter)
        Create new String Joiner.
        参数:
        delimiter - the delimiter to join multi string items, can not be null
        返回:
        Joiner
      • join

        public java.lang.String join​(@NonNull java.lang.Iterable<?> values)
        Join strings, with prefix, suffix, and delimiter
        参数:
        values - the string items
        返回:
        new string
      • join

        public java.lang.String join​(@Nullable java.lang.Object @NonNull ... values)
        Join strings, with prefix, suffix, and delimiter
        参数:
        values - the string items
        返回:
        new string
      • withPrefix

        public Joiner withPrefix​(java.lang.CharSequence prefix)
        Return a new Joiner which using the given prefix for joined string result.
      • withSuffix

        public Joiner withSuffix​(java.lang.CharSequence suffix)
        Return a new Joiner which using the given suffix for joined string result.
      • skipNulls

        public Joiner skipNulls()
        Return a new Joiner with skip the null elements.
        返回:
        new Joiner
      • nullToEmpty

        public Joiner nullToEmpty()
        Return a new Joiner which treat null elements as empty str instead of "null". This setting works only when skipNulls is false
        返回:
        new Joiner
      • skipEmpty

        public Joiner skipEmpty()
        Return a new Joiner which skip empty strings. Set skipEmpty to true would not skip null values, but if nullToEmpty is be set also, the null values would be skipped.