chaokunyang commented on code in PR #2036:
URL: https://github.com/apache/fury/pull/2036#discussion_r2052618509


##########
java/fury-core/src/main/java/org/apache/fury/serializer/AbstractObjectSerializer.java:
##########
@@ -826,69 +962,50 @@ protected T newBean() {
     cnt = 0;
     GenericTypeField[] otherFields = new 
GenericTypeField[grouper.getOtherDescriptors().size()];
     for (Descriptor descriptor : grouper.getOtherDescriptors()) {
-      GenericTypeField genericTypeField =
-          new GenericTypeField(
-              descriptor.getTypeRef(),
-              descriptor.getDeclaringClass() + "." + descriptor.getName(),
-              descriptor.getField() != null
-                  ? FieldAccessor.createAccessor(descriptor.getField())
-                  : null,
-              fury);
+      GenericTypeField genericTypeField = new GenericTypeField(fury, 
descriptor);
       otherFields[cnt++] = genericTypeField;
     }
     cnt = 0;
     Collection<Descriptor> collections = grouper.getCollectionDescriptors();
     Collection<Descriptor> maps = grouper.getMapDescriptors();
     GenericTypeField[] containerFields = new 
GenericTypeField[collections.size() + maps.size()];
     for (Descriptor d : collections) {
-      containerFields[cnt++] = buildContainerField(fury, d);
+      containerFields[cnt++] = new GenericTypeField(fury, d);
     }
     for (Descriptor d : maps) {
-      containerFields[cnt++] = buildContainerField(fury, d);
+      containerFields[cnt++] = new GenericTypeField(fury, d);
     }
     return Tuple3.of(Tuple2.of(finalFields, isFinal), otherFields, 
containerFields);
   }
 
-  private static FinalTypeField buildFinalTypeField(Fury fury, Descriptor d) {
-    return new FinalTypeField(
-        d.getTypeRef(),
-        d.getDeclaringClass() + "." + d.getName(),
-        // `d.getField()` will be null when peer class doesn't have this field.
-        d.getField() != null ? FieldAccessor.createAccessor(d.getField()) : 
null,
-        fury);
-  }
-
-  private static GenericTypeField buildContainerField(Fury fury, Descriptor d) 
{
-    return new GenericTypeField(
-        d.getTypeRef(),
-        d.getDeclaringClass() + "." + d.getName(),
-        d.getField() != null ? FieldAccessor.createAccessor(d.getField()) : 
null,
-        fury);
-  }
-
   public static class InternalFieldInfo {
-    private final TypeRef<?> typeRef;
+    protected final TypeRef<?> typeRef;
     protected final short classId;
     protected final String qualifiedFieldName;
     protected final FieldAccessor fieldAccessor;
+    protected boolean nullable;
 
-    private InternalFieldInfo(
-        TypeRef<?> typeRef, short classId, String qualifiedFieldName, 
FieldAccessor fieldAccessor) {
-      this.typeRef = typeRef;
+    private InternalFieldInfo(Descriptor d, short classId) {
+      this.typeRef = d.getTypeRef();
       this.classId = classId;
-      this.qualifiedFieldName = qualifiedFieldName;
-      this.fieldAccessor = fieldAccessor;
+      this.qualifiedFieldName = d.getDeclaringClass() + "." + d.getName();
+      this.fieldAccessor = d.getField() != null ? 
FieldAccessor.createAccessor(d.getField()) : null;
+      this.nullable = d.getFuryField() == null || d.getFuryField().nullable();

Review Comment:
   Need to check whether type of field is primitive



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to