diff --git a/src/main/java/org/influxdb/dto/Point.java b/src/main/java/org/influxdb/dto/Point.java index 96069026c..da9ff7386 100755 --- a/src/main/java/org/influxdb/dto/Point.java +++ b/src/main/java/org/influxdb/dto/Point.java @@ -526,7 +526,7 @@ private int concatenatedFields(final StringBuilder sb) { escapeKey(sb, field.getKey()); sb.append('='); if (value instanceof Number) { - if (value instanceof Double || value instanceof Float || value instanceof BigDecimal) { + if (isValidInstanceType(value)) { sb.append(NUMBER_FORMATTER.get().format(value)); } else { sb.append(value).append('i'); @@ -554,6 +554,10 @@ private int concatenatedFields(final StringBuilder sb) { return fieldCount; } + private boolean isValidInstanceType(Object value){ + return value instanceof Double || value instanceof Float || value instanceof BigDecimal; + } + static void escapeKey(final StringBuilder sb, final String key) { for (int i = 0; i < key.length(); i++) { switch (key.charAt(i)) { diff --git a/src/main/java/org/influxdb/impl/InfluxDBMapper.java b/src/main/java/org/influxdb/impl/InfluxDBMapper.java index 700a960cf..58a6e4c51 100644 --- a/src/main/java/org/influxdb/impl/InfluxDBMapper.java +++ b/src/main/java/org/influxdb/impl/InfluxDBMapper.java @@ -21,6 +21,34 @@ public InfluxDBMapper(final InfluxDB influxDB) { this.influxDB = influxDB; } + String getDatabaseName(final Class> clazz) { + return ((Measurement) clazz.getAnnotation(Measurement.class)).database(); + } + + /** + *
+ * Process a {@link QueryResult} object returned by the InfluxDB client inspecting the internal + * data structure and creating the respective object instances based on the Class passed as + * parameter. + *
+ * + * @param queryResult the InfluxDB result object + * @param clazz the Class that will be used to hold your measurement data + * @paramclazz
parameter is not annotated with @Measurement or it was not
+ * possible to define the values of your POJO (e.g. due to an unsupported field type).
+ */
+ public - * Process a {@link QueryResult} object returned by the InfluxDB client inspecting the internal - * data structure and creating the respective object instances based on the Class passed as - * parameter. - *
- * - * @param queryResult the InfluxDB result object - * @param clazz the Class that will be used to hold your measurement data - * @paramclazz
parameter is not annotated with @Measurement or it was not
- * possible to define the values of your POJO (e.g. due to an unsupported field type).
- */
- public
* Process a {@link QueryResult} object returned by the InfluxDB client inspecting the internal
@@ -231,10 +207,6 @@ String getMeasurementName(final Class> clazz) {
return ((Measurement) clazz.getAnnotation(Measurement.class)).name();
}
- String getDatabaseName(final Class> clazz) {
- return ((Measurement) clazz.getAnnotation(Measurement.class)).database();
- }
-
String getRetentionPolicy(final Class> clazz) {
return ((Measurement) clazz.getAnnotation(Measurement.class)).retentionPolicy();
}
diff --git a/src/main/java/org/influxdb/impl/Preconditions.java b/src/main/java/org/influxdb/impl/Preconditions.java
index 1e34204a3..b996b6a06 100644
--- a/src/main/java/org/influxdb/impl/Preconditions.java
+++ b/src/main/java/org/influxdb/impl/Preconditions.java
@@ -1,5 +1,7 @@
package org.influxdb.impl;
+import java.util.regex.Pattern;
+
/**
* Functions for parameter validation.
*
@@ -7,6 +9,8 @@
*/
public final class Preconditions {
+ private static final String DURATION_REGULAR_EXPRESSION = "(\\d+[wdmhs])+|inf";
+
private Preconditions() {
}
@@ -54,7 +58,7 @@ public static void checkNotNegativeNumber(final Number number, final String name
* @throws IllegalArgumentException if the given duration is not valid.
*/
public static void checkDuration(final String duration, final String name) throws IllegalArgumentException {
- if (!duration.matches("(\\d+[wdmhs])+|inf")) {
+ if (!duration.matches(DURATION_REGULAR_EXPRESSION)) {
throw new IllegalArgumentException("Invalid InfluxDB duration: " + duration
+ " for " + name);
}
diff --git a/src/main/java/org/influxdb/impl/RetryCapableBatchWriter.java b/src/main/java/org/influxdb/impl/RetryCapableBatchWriter.java
index e2b08190b..806302de7 100644
--- a/src/main/java/org/influxdb/impl/RetryCapableBatchWriter.java
+++ b/src/main/java/org/influxdb/impl/RetryCapableBatchWriter.java
@@ -67,6 +67,12 @@ private WriteResult(final InfluxDBException e) {
@Override
public synchronized void write(final Collection