This is an automated email from the ASF dual-hosted git repository. dfoulks pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/activemq-nms-openwire-generator.git
commit 83c9843e6575e842ff165d21134055f2874f2743 Author: Timothy A. Bish <[email protected]> AuthorDate: Wed Sep 1 20:14:26 2010 +0000 Update the NMS Commands and Marshalers generator to produce somewhat cleaner code, removes unneeded using statements. --- .../tool/commands/CommandClassGenerator.java | 23 +++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/apache/activemq/nms/openwire/tool/commands/CommandClassGenerator.java b/src/main/java/org/apache/activemq/nms/openwire/tool/commands/CommandClassGenerator.java index fc2c229..20c4782 100644 --- a/src/main/java/org/apache/activemq/nms/openwire/tool/commands/CommandClassGenerator.java +++ b/src/main/java/org/apache/activemq/nms/openwire/tool/commands/CommandClassGenerator.java @@ -104,6 +104,7 @@ public class CommandClassGenerator extends CommandCodeGenerator { out.println(" {"); out.println(" return Equals(("+getClassName()+") that);"); out.println(" }"); + out.println(""); out.println(" return false;"); out.println(" }"); out.println(""); @@ -202,6 +203,11 @@ public class CommandClassGenerator extends CommandCodeGenerator { protected void generateToStringBody( PrintWriter out ) { + if( getProperties().isEmpty() ) { + out.println(" return GetType().Name + \"[ ]\";"); + return; + } + out.println(" return GetType().Name + \"[ \" + "); if( getBaseClassName().equals( "BaseCommand" ) ) { @@ -277,16 +283,19 @@ public class CommandClassGenerator extends CommandCodeGenerator { protected void generateEqualsBody( PrintWriter out ) { - for( JProperty property : getProperties() ) { - String accessorName = property.getSimpleName(); + if( !getProperties().isEmpty() ) { + for( JProperty property : getProperties() ) { + String accessorName = property.getSimpleName(); - out.println(" if(!Equals(this."+accessorName+", that."+accessorName+"))"); - out.println(" {"); - out.println(" return false;"); - out.println(" }"); + out.println(" if(!Equals(this."+accessorName+", that."+accessorName+"))"); + out.println(" {"); + out.println(" return false;"); + out.println(" }"); + } + + out.println(""); } - out.println(""); out.println(" return true;"); }
