melloware commented on code in PR #711:
URL: https://github.com/apache/myfaces/pull/711#discussion_r1595338303


##########
impl/src/main/java/org/apache/myfaces/push/Json.java:
##########
@@ -111,12 +112,45 @@ else if (object instanceof Class<?>)
         {
             encode(((Class<?>) object).getName(), builder);
         }
+        else if (object instanceof Record)
+        {
+            encodeRecord(object, builder);
+        }
         else
         {
             encodeBean(object, builder);
         }
     }
 
+    private static void encodeRecord(Object recordObject, StringBuilder 
builder) {
+
+        builder.append('{');
+        boolean fieldsFound = false;
+
+        for (Field field : recordObject.getClass().getDeclaredFields())
+        {
+            field.setAccessible(true);
+            fieldsFound = true;
+            String name = field.getName();
+            builder.append(name);
+            builder.append(':');
+            try {
+                encode(field.get(recordObject), builder);
+            } catch (IllegalArgumentException e) {
+                e.printStackTrace();
+            } catch (IllegalAccessException e) {
+                e.printStackTrace();
+            }

Review Comment:
   I feel like we should throw some sort of unchecked exception here right?



-- 
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: dev-unsubscr...@myfaces.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to