Hi devs, I've already sent a proposal for EqualsBuilder and HashCodeBuilder (see http://markmail.org/message/ewbizvcx4zj432il) but only Sergiu answered. So resending as a VOTE and adding ToStringBuilder
For ToStringBuilder the idea is to create a XWikiStyle (see https://gist.github.com/2164507 ) And then to use it as in: @Override public String toString() { ToStringBuilder builder = new ToStringBuilder(this, new XWikiStyle()); builder = builder.append("Typed", isTyped()) .append("Type", getType().getScheme()); if (getReference() != null) { builder = builder.append("Reference", getReference()); } if (!getBaseReferences().isEmpty()) { builder = builder.append("Base References", getBaseReferences()); } Map<String, String> params = getParameters(); if (!params.isEmpty()) { builder = builder.append("Parameters", params); } return builder.toString(); } For the record this generates stuff like the following which is based on our current practices: "Typed = [true] Type = [doc] Reference = [reference] Base References = [[baseref1], [baseref2]] Parameters = [[name1] = [value1], [name2] = [value2]]" The rationale for using ToStringBuilder is: * It reduces our boilerplate code by at least 50% * It makes all our toString implementation consistent and easy to write Now all that remains is to decide where to put the XWikiStyle class. Of course it has to go in XWiki Commons somewhere but where? I'm proposing several possibilities: * xwiki-commons-logging (existing module): the rationale would be that the toString() is usually used for logging. The package would be org.xwiki.logging.text. I'm wondering if we should make this class internal too. * xwiki-commons-text (new module): I'm not sure what else we would put in there * xwiki-commons-util (new module): I don't like to have a module with no specific domain but it could be temporary till there are more stuff that make a domain So here's my +1. My only doubt is where to put it. Right now I'd be tempted to put it in xwiki-commons-logging so that we don't create a new module. Thanks -Vincent _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs

