gnodet-bot commented on code in PR #27809:
URL: https://github.com/apache/camel/pull/27809#discussion_r4268604740


##########
core/camel-core-model/src/main/java/org/apache/camel/model/UnmarshalDefinition.java:
##########
@@ -176,11 +176,15 @@ public String toString() {
     }
 
     protected String description() {
-        if (dataFormatType != null) {
-            return dataFormatType.toString();
-        } else {
+        if (dataFormatType == null) {
             return "";
         }
+        // the name of the data format (such as jackson or csv), as its 
toString is the object for most data formats
+        String name = dataFormatType.getDataFormatName();
+        if (name == null && dataFormatType.getDataFormat() != null) {
+            name = dataFormatType.getDataFormat().getClass().getSimpleName();

Review Comment:
   💡 Same issue as in `MarshalDefinition`: if the `DataFormat` instance 
implements `DataFormatName`, its declared name is ignored in favour of the 
class simple name.
   
   Consider:
   ```suggestion
               if (dataFormatType.getDataFormat() instanceof DataFormatName 
dfn) {
                   name = dfn.getDataFormatName();
               }
               if (name == null) {
                   name = 
dataFormatType.getDataFormat().getClass().getSimpleName();
               }
   ```



##########
core/camel-core-model/src/main/java/org/apache/camel/model/MarshalDefinition.java:
##########
@@ -178,7 +178,15 @@ public String toString() {
     }
 
     protected String description() {
-        return dataFormatType != null ? dataFormatType.toString() : "";
+        if (dataFormatType == null) {
+            return "";
+        }
+        // the name of the data format (such as jackson or csv), as its 
toString is the object for most data formats
+        String name = dataFormatType.getDataFormatName();
+        if (name == null && dataFormatType.getDataFormat() != null) {
+            name = dataFormatType.getDataFormat().getClass().getSimpleName();

Review Comment:
   💡 If `dataFormatType.getDataFormat()` implements `DataFormatName`, its 
`getDataFormatName()` is ignored here — the code falls back directly to 
`getClass().getSimpleName()`. The `DataFormatDefinition(DataFormat)` 
constructor only sets `this.dataFormat`, leaving `this.dataFormatName` null.
   
   Consider:
   ```suggestion
               if (dataFormatType.getDataFormat() instanceof DataFormatName 
dfn) {
                   name = dfn.getDataFormatName();
               }
               if (name == null) {
                   name = 
dataFormatType.getDataFormat().getClass().getSimpleName();
               }
   ```



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