ashley-taylor commented on code in PR #3425:
URL: https://github.com/apache/avro/pull/3425#discussion_r2216956519


##########
lang/java/avro/src/main/java/org/apache/avro/reflect/ReflectionUtil.java:
##########
@@ -188,4 +189,28 @@ public static <V, R> Function<V, R> 
getConstructorAsFunction(Class<V> parameterC
     }
   }
 
+  protected static AvroEncode getAvroEncode(Field field) {
+    var enc = field.getAnnotation(AvroEncode.class);
+    if (enc != null) {
+      return enc;
+    } else {
+      return getAvroEncode(field.getType());
+    }
+  }
+
+  protected static AvroEncode getAvroEncode(Class<?> clazz) {
+    if (clazz == null) {
+      return null;
+    }
+    AvroEncode enc = clazz.getAnnotation(AvroEncode.class);
+    if (enc != null) {
+      return enc;
+    }
+    // try superclasses
+    Class<?> superclass = clazz.getSuperclass();
+    if (superclass != null && superclass != Object.class) {
+      return getAvroEncode(superclass);
+    }

Review Comment:
   Done. So handy to know this now. Can think of several times this would have 
been useful.



-- 
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]

Reply via email to