highsource / jaxb2-basics

Useful plugins and tools for JAXB2.
BSD 2-Clause "Simplified" License
109 stars 54 forks source link

unnecessary, emberracing blocks in the generated code at equals(), hashCode(), toString(), appendFeilds() generated by SimpleEqualsPlugin, SimpleHashCodePlugin etc. #102

Closed cstenkes closed 5 years ago

cstenkes commented 5 years ago

For example:

public StringBuilder appendFields(ObjectLocator locator, StringBuilder buffer, ToStringStrategy2 strategy) {
                {
                    String theClientId;
                    theClientId = this.getClientId();
                    strategy.appendField(locator, this, "clientId", buffer, theClientId, (this.clientId!= null));
                }
                {
                    String theItemNo;
                    theItemNo = this.getItemNo();
                    strategy.appendField(locator, this, "itemNo", buffer, theItemNo, (this.itemNo!= null));
                }

This should be looked like:

public StringBuilder appendFields(ObjectLocator locator, StringBuilder buffer, ToStringStrategy2 strategy) {             
                    String theClientId = this.getClientId();
                    strategy.appendField(locator, this, "clientId", buffer, theClientId, (this.clientId!= null));                
                    String theItemNo = this.getItemNo();
                    strategy.appendField(locator, this, "itemNo", buffer, theItemNo, (this.itemNo!= null));
highsource commented 5 years ago

I think the code is more readable with one block per field. I would like to leave them as is.