davsclaus commented on code in PR #30035:
URL: https://github.com/apache/camel/pull/30035#discussion_r4579439687


##########
dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/TransformRoute.java:
##########
@@ -181,6 +184,23 @@ protected void doAddInitialProperty(KameletMain main) {
         return printDump(target);
     }
 
+    /**
+     * The Java route with the class named after the file it is written to: a 
class must have the name of its file, and
+     * --output=Out.java got the class named after the route file 
(CAMEL-26931).
+     */
+    static String withClassName(String java, String fileName, Path out) {
+        String wanted = out.getFileName().toString();
+        if (!wanted.endsWith(".java") || fileName == null || 
!fileName.endsWith(".java")) {
+            return java;
+        }
+        wanted = wanted.substring(0, wanted.length() - ".java".length());
+        String current = fileName.substring(0, fileName.length() - 
".java".length());
+        if (wanted.equals(current) || !SourceVersion.isName(wanted)) {

Review Comment:
   Fixed in 923885798966: the check is now `SourceVersion.isIdentifier(wanted) 
&& !SourceVersion.isKeyword(wanted)`, so `--output=My.Route.java` keeps the 
class name of the route. 
`TransformRouteTest.aJavaFileWhoseNameIsNoClassNameKeepsTheClassName` covers it 
(it fails with `isName`).
   
   _Claude Code on behalf of Claus Ibsen (davsclaus)_



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