CAMEL-9273: Polished. This closes #995.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/f40d087d Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/f40d087d Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/f40d087d Branch: refs/heads/master Commit: f40d087d4284acb7a28595a52323e04d97ba1110 Parents: 9839026 Author: Claus Ibsen <davscl...@apache.org> Authored: Wed May 25 17:06:47 2016 +0200 Committer: Claus Ibsen <davscl...@apache.org> Committed: Wed May 25 17:06:47 2016 +0200 ---------------------------------------------------------------------- .../component/weather/WeatherComponent.java | 7 ------ .../component/weather/WeatherConfiguration.java | 23 ++++++-------------- .../component/weather/WeatherQueryTest.java | 2 +- 3 files changed, 8 insertions(+), 24 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/f40d087d/components/camel-weather/src/main/java/org/apache/camel/component/weather/WeatherComponent.java ---------------------------------------------------------------------- diff --git a/components/camel-weather/src/main/java/org/apache/camel/component/weather/WeatherComponent.java b/components/camel-weather/src/main/java/org/apache/camel/component/weather/WeatherComponent.java index 884a16a..568bd82 100644 --- a/components/camel-weather/src/main/java/org/apache/camel/component/weather/WeatherComponent.java +++ b/components/camel-weather/src/main/java/org/apache/camel/component/weather/WeatherComponent.java @@ -52,13 +52,6 @@ public class WeatherComponent extends UriEndpointComponent { protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception { WeatherConfiguration configuration = new WeatherConfiguration(this); - String ids = getAndRemoveParameter(parameters, "ids", String.class); - Iterator<?> it = ObjectHelper.createIterator(ids); - while (it.hasNext()) { - String id = (String) it.next(); - configuration.addId(id); - } - // and then override from parameters setProperties(configuration, parameters); http://git-wip-us.apache.org/repos/asf/camel/blob/f40d087d/components/camel-weather/src/main/java/org/apache/camel/component/weather/WeatherConfiguration.java ---------------------------------------------------------------------- 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 aaff564..7c7be48 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 @@ -32,7 +32,6 @@ import org.apache.commons.httpclient.HttpConnectionManager; import static org.apache.camel.component.weather.WeatherLanguage.en; import static org.apache.camel.component.weather.WeatherMode.JSON; -import static org.apache.camel.component.weather.WeatherUnits.METRIC; import static org.apache.camel.util.ObjectHelper.notNull; @UriParams @@ -69,7 +68,7 @@ public class WeatherConfiguration { private String headerName; @UriParam private String zip; - @UriParam + @UriParam(javaType = "java.lang.String") private List<String> ids; @UriParam private Integer cnt; @@ -371,28 +370,20 @@ public class WeatherConfiguration { return (List<String>) ids; } - public void addId(String id) { + /** + * 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<>(); } - ids.add(id); - } - - /** - * List of id's of city/stations - */ - public void setIds(String id, String... ids) { Iterator<?> it = ObjectHelper.createIterator(id); while (it.hasNext()) { String myId = (String) it.next(); - addId(myId); + ids.add(myId); } - this.ids = Arrays.asList(ids); } - /** - * List of id's of city/stations - */ public void setIds(List<String> ids) { this.ids = ids; } @@ -413,7 +404,7 @@ public class WeatherConfiguration { } /** - * The API to be use (current, forecast/3 hour, forecast daily, station + * The API to be use (current, forecast/3 hour, forecast daily, station) */ public void setWeatherApi(WeatherApi weatherApi) { this.weatherApi = weatherApi; http://git-wip-us.apache.org/repos/asf/camel/blob/f40d087d/components/camel-weather/src/test/java/org/apache/camel/component/weather/WeatherQueryTest.java ---------------------------------------------------------------------- diff --git a/components/camel-weather/src/test/java/org/apache/camel/component/weather/WeatherQueryTest.java b/components/camel-weather/src/test/java/org/apache/camel/component/weather/WeatherQueryTest.java index 910f5f8..1b0683e 100644 --- a/components/camel-weather/src/test/java/org/apache/camel/component/weather/WeatherQueryTest.java +++ b/components/camel-weather/src/test/java/org/apache/camel/component/weather/WeatherQueryTest.java @@ -169,7 +169,7 @@ public class WeatherQueryTest { @Test public void testMultiIdQuery() throws Exception { WeatherConfiguration weatherConfiguration = new WeatherConfiguration(new WeatherComponent()); - weatherConfiguration.setIds("524901", "703448"); + weatherConfiguration.setIds("524901,703448"); weatherConfiguration.setMode(WeatherMode.JSON); weatherConfiguration.setLanguage(WeatherLanguage.nl); weatherConfiguration.setAppid(APPID);