You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by df...@apache.org on 2021/04/09 20:12:28 UTC
[activemq-nms-openwire-generator] 23/32: Update the NMS Commands
and Marshalers generator to produce somewhat cleaner code,
removes unneeded using statements.
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 39165edc1bb0a0c96935f093788ffa43d69f2b1d
Author: Timothy A. Bish <ta...@apache.org>
AuthorDate: Wed Sep 1 20:05:52 2010 +0000
Update the NMS Commands and Marshalers generator to produce somewhat cleaner code, removes unneeded using statements.
---
.../tool/commands/CommandClassGenerator.java | 23 +++++++++++++---------
.../marshalers/AmqCSharpMarshallersGenerator.java | 8 --------
2 files changed, 14 insertions(+), 17 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 4651aa2..fc2c229 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
@@ -197,7 +197,7 @@ public class CommandClassGenerator extends CommandCodeGenerator {
}
protected void generateVisitBody( PrintWriter out ) {
- out.println(" return visitor.process"+getClassName()+"( this );");
+ out.println(" return visitor.process"+getClassName()+"(this);");
}
protected void generateToStringBody( PrintWriter out ) {
@@ -257,17 +257,22 @@ public class CommandClassGenerator extends CommandCodeGenerator {
}
protected void generateHashCodeBody( PrintWriter out ) {
- out.println(" int answer = 0;");
- out.println("");
- for( JProperty property : getProperties() ) {
- String accessorName = property.getSimpleName();
+ if( getProperties().isEmpty() ) {
+ out.println(" return HashCode(this);");
+ } else {
+ out.println(" int answer = 0;");
+ out.println("");
- out.println(" answer = (answer * 37) + HashCode("+accessorName+");");
- }
+ for( JProperty property : getProperties() ) {
+ String accessorName = property.getSimpleName();
- out.println("");
- out.println(" return answer;");
+ out.println(" answer = (answer * 37) + HashCode("+accessorName+");");
+ }
+
+ out.println("");
+ out.println(" return answer;");
+ }
}
protected void generateEqualsBody( PrintWriter out ) {
diff --git a/src/main/java/org/apache/activemq/nms/openwire/tool/marshalers/AmqCSharpMarshallersGenerator.java b/src/main/java/org/apache/activemq/nms/openwire/tool/marshalers/AmqCSharpMarshallersGenerator.java
index 7dbc643..8fe64e2 100644
--- a/src/main/java/org/apache/activemq/nms/openwire/tool/marshalers/AmqCSharpMarshallersGenerator.java
+++ b/src/main/java/org/apache/activemq/nms/openwire/tool/marshalers/AmqCSharpMarshallersGenerator.java
@@ -343,14 +343,6 @@ out.println(" */");
out.println(" *");
out.println(" */");
out.println("");
- out.println("using System;");
- out.println("using System.Collections;");
- out.println("using System.IO;");
- out.println("");
- out.println("using Apache.NMS.ActiveMQ.Commands;");
- out.println("using Apache.NMS.ActiveMQ.OpenWire;");
- out.println("using Apache.NMS.ActiveMQ.OpenWire.V" + getOpenwireVersion() + ";");
- out.println("");
out.println("namespace Apache.NMS.ActiveMQ.OpenWire.V" + getOpenwireVersion() + "");
out.println("{");
out.println(" /// <summary>");