You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2025/07/23 09:53:46 UTC
(camel) branch CAMEL-17339-weather created (now eb9982f9554)
This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a change to branch CAMEL-17339-weather
in repository https://gitbox.apache.org/repos/asf/camel.git
at eb9982f9554 CAMEL-17339 - Avoid List<String> as configuration parameter types in Endpoint configurations - Camel Weather
This branch includes the following new commits:
new eb9982f9554 CAMEL-17339 - Avoid List<String> as configuration parameter types in Endpoint configurations - Camel Weather
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(camel) 01/01: CAMEL-17339 - Avoid List as configuration parameter types in Endpoint configurations - Camel Weather
Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a commit to branch CAMEL-17339-weather
in repository https://gitbox.apache.org/repos/asf/camel.git
commit eb9982f9554c13ba31f0389b674a5a782d356bfa
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Jul 23 11:52:45 2025 +0200
CAMEL-17339 - Avoid List<String> as configuration parameter types in Endpoint configurations - Camel Weather
Signed-off-by: Andrea Cosentino <an...@gmail.com>
---
.../component/weather/WeatherConfiguration.java | 28 +++++++++-------------
.../camel/component/weather/WeatherQuery.java | 4 ++--
.../ROOT/pages/camel-4x-upgrade-guide-4_14.adoc | 4 ++++
3 files changed, 17 insertions(+), 19 deletions(-)
diff --git a/components/camel-weather/src/main/java/org/apache/camel/component/weather/WeatherConfiguration.java b/components/camel-weather/src/main/java/org/apache/camel/component/weather/WeatherConfiguration.java
index 39b59a3dc9a..5a7ddf7734a 100644
--- a/components/camel-weather/src/main/java/org/apache/camel/component/weather/WeatherConfiguration.java
+++ b/components/camel-weather/src/main/java/org/apache/camel/component/weather/WeatherConfiguration.java
@@ -16,8 +16,6 @@
*/
package org.apache.camel.component.weather;
-import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
import java.util.Scanner;
@@ -27,7 +25,6 @@ import org.apache.camel.spi.Metadata;
import org.apache.camel.spi.UriParam;
import org.apache.camel.spi.UriParams;
import org.apache.camel.spi.UriPath;
-import org.apache.camel.support.ObjectHelper;
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
import org.apache.hc.client5.http.impl.classic.HttpClients;
@@ -71,7 +68,7 @@ public class WeatherConfiguration {
@UriParam(label = "filter")
private String zip;
@UriParam(label = "filter", javaType = "java.lang.String")
- private List<String> ids;
+ private String ids;
@UriParam(label = "filter")
private Integer cnt;
@UriParam(label = "security")
@@ -257,25 +254,22 @@ public class WeatherConfiguration {
this.zip = zip;
}
- public List<String> getIds() {
+ public String getIds() {
return ids;
}
- /**
- * List of id's of city/stations. You can separate multiple ids by comma.
- */
- public void setIds(String id) {
- if (ids == null) {
- ids = new ArrayList<>();
- }
- Iterator<?> it = ObjectHelper.createIterator(id);
- while (it.hasNext()) {
- String myId = (String) it.next();
- ids.add(myId);
+ public List<String> getIdsAsList() {
+ if (ids != null) {
+ return List.of(ids.split(","));
+ } else {
+ return null;
}
}
- public void setIds(List<String> ids) {
+ /**
+ * List of id's of city/stations. You can separate multiple ids by comma.
+ */
+ public void setIds(String ids) {
this.ids = ids;
}
diff --git a/components/camel-weather/src/main/java/org/apache/camel/component/weather/WeatherQuery.java b/components/camel-weather/src/main/java/org/apache/camel/component/weather/WeatherQuery.java
index db581e646ef..4550af8c677 100644
--- a/components/camel-weather/src/main/java/org/apache/camel/component/weather/WeatherQuery.java
+++ b/components/camel-weather/src/main/java/org/apache/camel/component/weather/WeatherQuery.java
@@ -50,7 +50,7 @@ public class WeatherQuery {
} else if (!isEmpty(weatherConfiguration.getZip())) {
location = "zip=" + weatherConfiguration.getZip();
} else if (weatherConfiguration.getIds() != null && !weatherConfiguration.getIds().isEmpty()) {
- location = "id=" + String.join(",", weatherConfiguration.getIds());
+ location = "id=" + weatherConfiguration.getIds();
} else if (isEmpty(location) || "current".equals(location)) {
GeoLocation geoLocation = getCurrentGeoLocation();
weatherConfiguration.setLat(geoLocation.getLatitude());
@@ -104,7 +104,7 @@ public class WeatherQuery {
answer = "find?";
}
} else if (weatherConfiguration.getIds() != null && !weatherConfiguration.getIds().isEmpty()) {
- if (weatherConfiguration.getIds().size() == 1) {
+ if (weatherConfiguration.getIdsAsList().size() == 1) {
if (!isEmpty(weatherConfiguration.getPeriod())) {
if (weatherConfiguration.getWeatherApi() == WeatherApi.Hourly) {
answer = "forecast?";
diff --git a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_14.adoc b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_14.adoc
index c015d5e96dc..b060534da84 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_14.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_14.adoc
@@ -42,3 +42,7 @@ The configKeys parameter for camel-dapr has been defined as String instead of Li
The availableZones parameter for camel-huawei-dms has been defined as String instead of List<String>. For the migration users will need to, eventually, define availableZones as a comma separated list of available zones instead of a List instance. For more information the related issue is CAMEL-17339.
+=== camel-weather
+
+The ids parameter for camel-weather has been defined as String instead of List<String>. For the migration users will need to, eventually, define ids as a comma separated list of id instead of a List instance. For more information the related issue is CAMEL-17339.
+