@@ -47,6 +47,7 @@ public class CouchbaseWeatherSource implements WeatherSource {
4747 private final CouchbaseConnector connector ;
4848 private final IdCoordinateSource coordinateSource ;
4949 private final String coordinateIdColumnName ;
50+ private final String timeStampPattern ;
5051
5152 /**
5253 * Instantiate a weather source utilising a connection to a couchbase instance obtained via the
@@ -58,13 +59,20 @@ public class CouchbaseWeatherSource implements WeatherSource {
5859 * @param coordinateSource Source to obtain actual coordinates from
5960 * @param weatherFactory Factory to transfer field to value mapping into actual java object
6061 * instances
62+ * @param timeStampPattern Pattern of time stamps to parse
6163 */
6264 public CouchbaseWeatherSource (
6365 CouchbaseConnector connector ,
6466 IdCoordinateSource coordinateSource ,
65- TimeBasedWeatherValueFactory weatherFactory ) {
67+ TimeBasedWeatherValueFactory weatherFactory ,
68+ String timeStampPattern ) {
6669 this (
67- connector , coordinateSource , DEFAULT_KEY_PREFIX , DEFAULT_NAMING_CONVENTION , weatherFactory );
70+ connector ,
71+ coordinateSource ,
72+ DEFAULT_KEY_PREFIX ,
73+ DEFAULT_TIMESTAMP_PATTERN ,
74+ DEFAULT_NAMING_CONVENTION ,
75+ weatherFactory );
6876 }
6977
7078 /**
@@ -77,15 +85,22 @@ public CouchbaseWeatherSource(
7785 * @param weatherFactory Factory to transfer field to value mapping into actual java object
7886 * instances
7987 * @deprecated Use {@link CouchbaseWeatherSource#CouchbaseWeatherSource(CouchbaseConnector,
80- * IdCoordinateSource, String, NamingConvention, TimeBasedWeatherValueFactory)} instead
88+ * IdCoordinateSource, String, String, NamingConvention, TimeBasedWeatherValueFactory)}
89+ * instead
8190 */
8291 @ Deprecated
8392 public CouchbaseWeatherSource (
8493 CouchbaseConnector connector ,
8594 IdCoordinateSource coordinateSource ,
8695 String keyPrefix ,
8796 TimeBasedWeatherValueFactory weatherFactory ) {
88- this (connector , coordinateSource , keyPrefix , DEFAULT_NAMING_CONVENTION , weatherFactory );
97+ this (
98+ connector ,
99+ coordinateSource ,
100+ keyPrefix ,
101+ DEFAULT_TIMESTAMP_PATTERN ,
102+ DEFAULT_NAMING_CONVENTION ,
103+ weatherFactory );
89104 }
90105
91106 /**
@@ -95,6 +110,7 @@ public CouchbaseWeatherSource(
95110 * @param connector Connector, that establishes the connection to the couchbase instance
96111 * @param coordinateSource Source to obtain actual coordinates from
97112 * @param keyPrefix Prefix of entries, that belong to weather
113+ * @param timeStampPattern Pattern of time stamps to parse
98114 * @param namingConvention the (case) convention, how columns are named
99115 * @param weatherFactory Factory to transfer field to value mapping into actual java object
100116 * instances
@@ -103,12 +119,14 @@ public CouchbaseWeatherSource(
103119 CouchbaseConnector connector ,
104120 IdCoordinateSource coordinateSource ,
105121 String keyPrefix ,
122+ String timeStampPattern ,
106123 NamingConvention namingConvention ,
107124 TimeBasedWeatherValueFactory weatherFactory ) {
108125 this .connector = connector ;
109126 this .coordinateSource = coordinateSource ;
110127 this .keyPrefix = keyPrefix ;
111128 this .weatherFactory = weatherFactory ;
129+ this .timeStampPattern = timeStampPattern ;
112130 this .namingConvention = namingConvention ;
113131 this .coordinateIdColumnName = weatherFactory .getCoordinateIdFieldString (namingConvention );
114132 }
@@ -188,7 +206,7 @@ public Optional<TimeBasedValue<WeatherValue>> getWeather(ZonedDateTime date, Poi
188206 public String generateWeatherKey (ZonedDateTime time , Integer coordinateId ) {
189207 String key = keyPrefix + "::" ;
190208 key += coordinateId + "::" ;
191- key += time .format (DateTimeFormatter .ofPattern (DEFAULT_TIMESTAMP_PATTERN ));
209+ key += time .format (DateTimeFormatter .ofPattern (timeStampPattern ));
192210 return key ;
193211 }
194212
0 commit comments