Skip to content

Commit b1e270a

Browse files
committed
Add shallow-copying clone method to properties classes.
1 parent 55e741a commit b1e270a

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

codegen.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,15 @@ def printClassInterfaces():
132132
print " }"
133133

134134

135+
def printClone(c):
136+
print
137+
print """ public Object clone()
138+
throws CloneNotSupportedException
139+
{
140+
return super.clone();
141+
}""" % \
142+
{"n": java_class_name(c.name)}
143+
135144
def printReadProperties(c):
136145
print
137146
print """ public void readPropertiesFrom(ContentHeaderPropertyReader reader)
@@ -171,7 +180,7 @@ def printPropertyDebug(c):
171180

172181
def printClassProperties(c):
173182
print
174-
print " public static class %s extends AMQContentHeader {" % ( java_class_name(c.name) + 'Properties')
183+
print " public static class %s extends AMQContentHeader implements Cloneable {" % ( java_class_name(c.name) + 'Properties')
175184
#property fields
176185
for f in c.fields:
177186
print " public %s %s;" % (java_property_type(spec, f.domain),java_field_name(f.name))
@@ -196,6 +205,7 @@ def printClassProperties(c):
196205
print " public int getClassId() { return %i; }" % (c.index)
197206
print " public java.lang.String getClassName() { return \"%s\"; }" % (c.name)
198207

208+
printClone(c)
199209
printReadProperties(c)
200210
printWriteProperties(c)
201211
printPropertyDebug(c)

test/src/com/rabbitmq/client/test/AllTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public static TestSuite suite() {
4343
suite.addTest(AMQConnectionTest.suite());
4444
suite.addTest(ValueOrExceptionTest.suite());
4545
suite.addTest(BrokenFramesTest.suite());
46+
suite.addTestSuite(ClonePropertiesTest.class);
4647
return suite;
4748
}
4849
}

0 commit comments

Comments
 (0)