Alternative to MoreObjects in Java 8 -


i want rid of dependency: import com.google.common.base.moreobjects;

is there simple and/or elegant way rewrite following tostring() function using java 8 native functions?

@override public string tostring() {   return moreobjects     .tostringhelper(this)     .add("userid", this.userid)     .add("timestamp", this.timestamp)     .tostring(); } 

you can use stringjoiner java.util package.

example:

@override public string tostring() {     return new stringjoiner(", ", classname.class.getsimplename() + "[", "]")     .add("userid=" + userid)     .add("timestamp=" + timestamp)     .tostring(); } 

Comments

Popular posts from this blog

xml - Extract substrings with XSLT -

math - "ELO Rating" and how does "TSR Rating" work? -

How can do a tuple comparison in coffeescript similar to that in python? -