henryf1991 commented on code in PR #2887:
URL: https://github.com/apache/avro/pull/2887#discussion_r1588318900
##########
lang/java/avro/src/main/java/org/apache/avro/reflect/ReflectData.java:
##########
@@ -802,6 +800,21 @@ private String simpleName(Class<?> c) {
return simpleName;
}
+ /*
+ * Function checks if there is @AvroTypeName annotation on the class. If
present
+ * then returns the value of the annotation else returns the package of the
+ * class
+ */
+ private String getNamespace(Class<?> c) {
+ AvroTypeName avroTypeName = c.getAnnotation(AvroTypeName.class);
+ if (avroTypeName != null) {
+ return avroTypeName.value();
+ }
+ if (c.getEnclosingClass() != null) // nested class
+ return c.getEnclosingClass().getName().replace('$', '.');
Review Comment:
@opwvhk Thats a great point! I was assuming that we should only be
overriding the namespace when the class has the AvroTypeName annotation.
Just to clarify if the class structure is as below:
```
@AvroTypeName("org.apache.avro.reflect.OverrideNamespace")
private static class NamespaceTest {
private static class EnclosingNamespaceTest {
}
}
```
When the schema definition is generated for EnclosingNamespaceTest.class,
the namespace should be org.apache.avro.reflect.OverrideNamespace ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]