public final class ToStringConfig extends Object implements Serializable
集合转成字符串
,将数组转成字符串
的参数配置.
- 连接符使用
DEFAULT_CONNECTOR
- 拼接null或者empty元素
- 如果元素是null,使用
StringUtils.EMPTY
替代拼接- 最后一个元素后面不拼接拼接符
ToStringStyle
,
StringUtils.join(Object[], String)
,
Serialized FormModifier and Type | Field and Description |
---|---|
static ToStringConfig |
DEFAULT_CONFIG
默认的转换参数.
|
static String |
DEFAULT_CONNECTOR
默认逗号连接
"," . |
static ToStringConfig |
IGNORE_NULL_OR_EMPTY_CONFIG
使用
DEFAULT_CONNECTOR 但是忽视 null 或者 empty 元素进行拼接的参数. |
Constructor and Description |
---|
ToStringConfig()
默认的构造函数.
|
ToStringConfig(String connector)
Instantiates a new to string config.
|
ToStringConfig(String connector,
boolean isJoinNullOrEmpty)
Instantiates a new to string config.
|
ToStringConfig(String connector,
boolean isJoinNullOrEmpty,
String prefix)
Instantiates a new to string config.
|
Modifier and Type | Method and Description |
---|---|
String |
getConnector()
获得 连接符,默认=
DEFAULT_CONNECTOR . |
boolean |
getIsJoinNullOrEmpty()
是否拼接null或者empty的元素,如果是true ,表示拼接,如果是false,那么拼接的时候跳过这个元素.
|
String |
getPrefix()
获得 循环拼接元素的时候,支持给每个元素拼接一个前缀.
|
void |
setConnector(String connector)
设置 连接符,默认=
DEFAULT_CONNECTOR . |
void |
setIsJoinNullOrEmpty(boolean isJoinNullOrEmpty)
是否拼接null或者empty的元素,如果是true ,表示拼接,如果是false,那么拼接的时候跳过这个元素.
|
void |
setPrefix(String prefix)
设置 循环拼接元素的时候,支持给每个元素拼接一个前缀.
|
String |
toString() |
public static final String DEFAULT_CONNECTOR
","
.public static final ToStringConfig DEFAULT_CONFIG
.
- 连接符使用
DEFAULT_CONNECTOR
- 拼接null或者empty元素
- 如果元素是null,使用
StringUtils.EMPTY
替代拼接- 最后一个元素后面不拼接拼接符
下面是调用 ConvertUtil.toString(java.util.Collection, ToStringConfig)
或者 ConvertUtil.toString(Object[], ToStringConfig)
的示例
ConvertUtil.toString(toList("feilong", "xinge"), DEFAULT_CONFIG) = "feilong,xinge"; ConvertUtil.toString(toList("feilong", "", "xinge", null), DEFAULT_CONFIG) = "feilong,,xinge,";
ToStringStyle.DEFAULT_STYLE
public static final ToStringConfig IGNORE_NULL_OR_EMPTY_CONFIG
DEFAULT_CONNECTOR
但是忽视 null 或者 empty 元素进行拼接的参数.
.
- 连接符使用
DEFAULT_CONNECTOR
- 不拼接null或者empty元素
- 最后一个元素后面不拼接拼接符
下面是调用 ConvertUtil.toString(java.util.Collection, ToStringConfig)
或者 ConvertUtil.toString(Object[], ToStringConfig)
的示例
ConvertUtil.toString(toList("feilong", "xinge"), IGNORE_NULL_OR_EMPTY_CONFIG) = "feilong,xinge"; ConvertUtil.toString(toList("feilong", "", "xinge", null), IGNORE_NULL_OR_EMPTY_CONFIG) = "feilong,xinge";
ToStringStyle.DEFAULT_STYLE
public ToStringConfig()
.
- 连接符使用
DEFAULT_CONNECTOR
- 拼接null或者empty元素
- 如果元素是null,使用
StringUtils.EMPTY
替代拼接- 最后一个元素后面不拼接拼接符
public ToStringConfig(String connector)
connector
- 连接符public ToStringConfig(String connector, boolean isJoinNullOrEmpty)
connector
- 连接符isJoinNullOrEmpty
- 是否拼接null或者empty的元素,如果是true ,表示拼接,如果是false,那么拼接的时候跳过这个元素public String getConnector()
DEFAULT_CONNECTOR
.public void setConnector(String connector)
DEFAULT_CONNECTOR
.connector
- the connector to setpublic boolean getIsJoinNullOrEmpty()
public void setIsJoinNullOrEmpty(boolean isJoinNullOrEmpty)
isJoinNullOrEmpty
- the isJoinNullOrEmpty to setpublic String getPrefix()
public void setPrefix(String prefix)
prefix
- the prefix to setCopyright © 2008-2019 by feilong