Zeyad2003 commented on PR #3970:
URL: https://github.com/apache/fineract/pull/3970#issuecomment-2229253245

   @vidakovic 
   
   The reason is that we're ultimately serializing an `Object`, not a specific 
generic type (T). Here’s the current code:
   
   ```java
       @Override // Used to serialize the CommandProcessingResult
       public String serializeResult(final Object object) {
           return this.commandProcessingResultSerializer.serialize(object);
       }
   
       @Override // Used to serialize the Map
       public String serialize(final Object object) {
           return this.excludeNothingWithPrettyPrintingOff.serialize(object);
       }
   ```
   
   With this setup, we could technically use a single ToApiJsonSerializer for 
both cases, and it would still work. However, if we were to switch the method 
signatures to use generics, the code would likely fail. This is why I swapped 
the places.
   
   > [!NOTE]
   > Here's the final executed code for serializing (left for 
`CommandProcessingResult` and right for `Map<String, Object>`):
   > ![Screenshot from 2024-07-15 
21-49-53](https://github.com/user-attachments/assets/43813d10-59ac-4de0-b562-1613719d9d43)
   


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