Guava-1.16类Joiner

全路径名:

com.google.common.base
Joiner

声明

@GwtCompatible
public class Joiner extends Object

简介

一个用分隔符合并文本片段的类,也可以合并数组,迭代,变量,甚至map。
可以将结果添加到一个Appendable类或者直接返回String。
如果没有指定skipNulls(),useForNull(String),那么合并的方法的任何参数是null都会报错。

注意:合并器的实例都是不可变的。a configuration method such as useForNull has no effect on the instance it is invoked on! You must store and use the new joiner instance returned by the method. This makes joiners thread-safe, and safe to store as static final constants.

配套的类

static classJoiner.MapJoiner
合并map的类。类似可以用到iterables和arrays。

方法

on
public static Joiner on(String separator)

public static Joiner on(char separator)

返回连接器。

appendTo
public  A appendTo(A appendable, Iterable parts)

public final  A appendTo(A appendable, Object[] parts)

public final  A appendTo(
      A appendable, @NullableDecl Object first, @NullableDecl Object second, Object... rest)
      throws IOException

public final StringBuilder appendTo(StringBuilder builder, Iterable parts)

public final StringBuilder appendTo(StringBuilder builder, Iterator parts)

public final StringBuilder appendTo(StringBuilder builder, Object[] parts)

public final StringBuilder appendTo(
      StringBuilder builder,
      @NullableDecl Object first,
      @NullableDecl Object second,
      Object... rest)

添加字符串。

join
 public final String join(Iterable parts)

public final String join(Object[] parts)

public final String join(
      @NullableDecl Object first, @NullableDecl Object second, Object... rest)

用连接符连接。

useForNull
public Joiner useForNull(String nullText)

可以处理null的joiner

skipNulls
public Joiner skipNulls()

跳过null的joiner

你可能感兴趣的:(Guava-1.16类Joiner)