今天看项目,发现一个不错的类:ToStringBuilder
ToStringBuilder在包 common-lang 中,主要用于一个类的格式化输出。
ToStringBuilder类中的append方法可以向该类添加基本类型、数组和对象 ,只有添加的方法才会被toString方法输出。
这个可以有效的控制toString 的输出,格式控制,String对象的+避免,减小内存开销
ToStringStyle类则是对输出的内容进行格式化。
例如:
public String toString() …{
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append(『name』, name)
.append(『age』, age)
.toString();
}
ToStringStyle参数说明:
1. DEFAULT_STYLE
Person@182f0db[name=John Doe,age=33,smoker=false]
2. MULTI_LINE_STYLE
Person@182f0db[
name=John Doe
age=33
smoker=false
]
3. NO_FIELD_NAMES_STYLE
Person@182f0db[John Doe,33,false]
4. SHORT_PREFIX_STYLE
Person[name=John Doe,age=33,smoker=false]
5. SIMPLE_STYLE
John Doe,33,false
相关推荐
org.apache.commons.lang.builder.ToStringBuilder.class org.apache.commons.lang.builder.ToStringStyle$DefaultToStringStyle.class org.apache.commons.lang.builder.ToStringStyle$MultiLineToStringStyle....
org.apache.commons.lang.builder.ToStringBuilder.class org.apache.commons.lang.builder.ToStringStyle$DefaultToStringStyle.class org.apache.commons.lang.builder.ToStringStyle$MultiLineToStringStyle....
org.apache.commons.commons-math3:3.6.1
import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.HttpException; import org.apache.commons.httpclient.HttpStatus; import org.apache.commons.httpclient.methods....
com.springsource.org.apache.commons.lang
jar包分享,你懂的 com.springsource.org.apache.commons.io-1.4.0.jar
org.apache.commons.lang所有包的集合,
org.apache.commons.lang jar包
需要先 import org.apache.commons.lang3.StringUtils; /* 内含 common-lang3.jar commons-lang3-3.9-bin.zip commons-lang3-3.9-src.zip 使用说明.txt*/ public static String getClientIp(HttpServletRequest ...
com.springsource.org.apache.commons.logging-1.1.1.jar
jar包,官方版本,自测可用
org.apache.commons.lang3.StringUtils.jar,打开是common-lang3.jar文件,以及使用方法,根据使用方法使用即可,绝对可靠
包含有org.apache.commons.lang3.StringUtils; org.apache.commons.lang3.reflect.FieldUtils等类
com.springsource.org.apache.commons.logging-sources-1.1.1.jar
jar包,官方版本,自测可用
Apache Commons Lang资源包,下载解压缩后,可获得api文档,源码,jar包,用于开发
org.apache.commons.lang.builder.ToStringBuilder.class org.apache.commons.lang.builder.ToStringStyle$DefaultToStringStyle.class org.apache.commons.lang.builder.ToStringStyle$MultiLineToStringStyle....
import org.apache.commons.lang.StringUtils; import org.apache.poi.hssf.usermodel.HSSFCell; import org.apache.poi.hssf.usermodel.HSSFCellStyle; import org.apache.poi.hssf.usermodel.HSSFFont; import org...
最新org.apache.commons.net..包完整、干净、实用
com.springsource.org.apache.commons.fileupload 自己打入本地Jar包即可