gnodet-bot commented on code in PR #28444:
URL: https://github.com/apache/camel/pull/28444#discussion_r4370518913
##########
core/camel-main/src/main/java/org/apache/camel/main/MainHelper.java:
##########
@@ -406,6 +417,37 @@ public static boolean setPropertiesOnTarget(
return rc;
}
+ /**
+ * The configurer of the data format or language that the option prefix,
such as camel.dataformat.jacksonXml. or
+ * camel.language.jsonpath., is about. They are found by their name
(jacksonXml-dataformat, jsonpath-language), as
+ * their name cannot always be told from their type.
+ *
+ * @param target the data format or language
+ * @return the configurer, or <tt>null</tt> for any other prefix,
when there is none, or when it is not the
Review Comment:
💬 **Nit:** `<tt>null</tt>` is deprecated HTML in modern Javadoc — prefer
`{@code null}`.
```suggestion
* @return the configurer, or {@code null} for any other prefix,
when there is none, or when it is not the
```
##########
core/camel-main/src/main/java/org/apache/camel/main/MainHelper.java:
##########
@@ -406,6 +417,37 @@ public static boolean setPropertiesOnTarget(
return rc;
}
+ /**
+ * The configurer of the data format or language that the option prefix,
such as camel.dataformat.jacksonXml. or
+ * camel.language.jsonpath., is about. They are found by their name
(jacksonXml-dataformat, jsonpath-language), as
+ * their name cannot always be told from their type.
+ *
+ * @param target the data format or language
+ * @return the configurer, or <tt>null</tt> for any other prefix,
when there is none, or when it is not the
+ * configurer of the type of the target (such as a custom
bean with the name of a data format)
+ */
+ public static PropertyConfigurer configurerByName(CamelContext context,
String optionPrefix, Object target) {
+ String kind;
+ if (optionPrefix.startsWith("camel.dataformat.")) {
+ kind = "dataformat";
+ } else if (optionPrefix.startsWith("camel.language.")) {
+ kind = "language";
+ } else {
+ return null;
+ }
+ String name = StringHelper.between(optionPrefix, "camel." + kind +
".", ".");
+ if (name == null || name.isEmpty()) {
+ return null;
+ }
+ PropertyConfigurer configurer
+ =
PluginHelper.getConfigurerResolver(context).resolvePropertyConfigurer(name +
"-" + kind, context);
+ // the generated configurer of a type is named after it
+ if (configurer != null &&
configurer.getClass().getName().equals(target.getClass().getName() +
"Configurer")) {
Review Comment:
💬 **Nit:** The type-match check works because the code generator enforces
the `<TargetClass>Configurer` naming convention. Consider a brief inline
comment to document this assumption, so it's clear this isn't an arbitrary
string check:
```suggestion
// the generated configurer of a type is named after it by the code
generator (PackageLanguageMojo / PackageDataFormatMojo)
if (configurer != null &&
configurer.getClass().getName().equals(target.getClass().getName() +
"Configurer")) {
```
--
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]