@Test void mapToBigDecimal() { FluxRecord record = new FluxRecord(0); record.getValues().put("value1", "12345678901234567000"); record.getValues().put("value2", 1234567890123456700L); record.getValues().put("value3", 1234567890.1234567); record.getValues().put("value4", 5.5D); BigDecimalBean bean = mapper.toPOJO(record, BigDecimalBean.class); Assertions.assertThat(bean.value1).isEqualByComparingTo(new BigDecimal("12345678901234567000")); Assertions.assertThat(bean.value2).isEqualByComparingTo(new BigDecimal("1234567890123456700")); Assertions.assertThat(bean.value3).isEqualByComparingTo(new BigDecimal("1234567890.1234567")); Assertions.assertThat(bean.value4).isEqualByComparingTo(new BigDecimal("5.5")); }
@Nonnull public <T> T toPOJO(@Nonnull final FluxRecord record, @Nonnull final Class<T> clazz) { Objects.requireNonNull(record, "Record is required"); Objects.requireNonNull(clazz, "Class type is required"); try { T pojo = clazz.newInstance(); Class<?> currentClazz = clazz; while (currentClazz != null) { Field[] fields = currentClazz.getDeclaredFields(); for (Field field : fields) { Column anno = field.getAnnotation(Column.class); String columnName = field.getName(); if (anno != null && !anno.name().isEmpty()) { columnName = anno.name(); } Map<String, Object> recordValues = record.getValues(); String col = null; if (recordValues.containsKey(columnName)) { col = columnName; } else if (recordValues.containsKey("_" + columnName)) { col = "_" + columnName; } if (col != null) { Object value = record.getValueByKey(col); setFieldValue(pojo, field, value); } } currentClazz = currentClazz.getSuperclass(); } return pojo; } catch (Exception e) { throw new InfluxException(e); } }
FluxResultMapper { @Nonnull public <T> T toPOJO(@Nonnull final FluxRecord record, @Nonnull final Class<T> clazz) { Objects.requireNonNull(record, "Record is required"); Objects.requireNonNull(clazz, "Class type is required"); try { T pojo = clazz.newInstance(); Class<?> currentClazz = clazz; while (currentClazz != null) { Field[] fields = currentClazz.getDeclaredFields(); for (Field field : fields) { Column anno = field.getAnnotation(Column.class); String columnName = field.getName(); if (anno != null && !anno.name().isEmpty()) { columnName = anno.name(); } Map<String, Object> recordValues = record.getValues(); String col = null; if (recordValues.containsKey(columnName)) { col = columnName; } else if (recordValues.containsKey("_" + columnName)) { col = "_" + columnName; } if (col != null) { Object value = record.getValueByKey(col); setFieldValue(pojo, field, value); } } currentClazz = currentClazz.getSuperclass(); } return pojo; } catch (Exception e) { throw new InfluxException(e); } } }
FluxResultMapper { @Nonnull public <T> T toPOJO(@Nonnull final FluxRecord record, @Nonnull final Class<T> clazz) { Objects.requireNonNull(record, "Record is required"); Objects.requireNonNull(clazz, "Class type is required"); try { T pojo = clazz.newInstance(); Class<?> currentClazz = clazz; while (currentClazz != null) { Field[] fields = currentClazz.getDeclaredFields(); for (Field field : fields) { Column anno = field.getAnnotation(Column.class); String columnName = field.getName(); if (anno != null && !anno.name().isEmpty()) { columnName = anno.name(); } Map<String, Object> recordValues = record.getValues(); String col = null; if (recordValues.containsKey(columnName)) { col = columnName; } else if (recordValues.containsKey("_" + columnName)) { col = "_" + columnName; } if (col != null) { Object value = record.getValueByKey(col); setFieldValue(pojo, field, value); } } currentClazz = currentClazz.getSuperclass(); } return pojo; } catch (Exception e) { throw new InfluxException(e); } }  }
FluxResultMapper { @Nonnull public <T> T toPOJO(@Nonnull final FluxRecord record, @Nonnull final Class<T> clazz) { Objects.requireNonNull(record, "Record is required"); Objects.requireNonNull(clazz, "Class type is required"); try { T pojo = clazz.newInstance(); Class<?> currentClazz = clazz; while (currentClazz != null) { Field[] fields = currentClazz.getDeclaredFields(); for (Field field : fields) { Column anno = field.getAnnotation(Column.class); String columnName = field.getName(); if (anno != null && !anno.name().isEmpty()) { columnName = anno.name(); } Map<String, Object> recordValues = record.getValues(); String col = null; if (recordValues.containsKey(columnName)) { col = columnName; } else if (recordValues.containsKey("_" + columnName)) { col = "_" + columnName; } if (col != null) { Object value = record.getValueByKey(col); setFieldValue(pojo, field, value); } } currentClazz = currentClazz.getSuperclass(); } return pojo; } catch (Exception e) { throw new InfluxException(e); } }  @Nonnull T toPOJO(@Nonnull final FluxRecord record, @Nonnull final Class<T> clazz); }
FluxResultMapper { @Nonnull public <T> T toPOJO(@Nonnull final FluxRecord record, @Nonnull final Class<T> clazz) { Objects.requireNonNull(record, "Record is required"); Objects.requireNonNull(clazz, "Class type is required"); try { T pojo = clazz.newInstance(); Class<?> currentClazz = clazz; while (currentClazz != null) { Field[] fields = currentClazz.getDeclaredFields(); for (Field field : fields) { Column anno = field.getAnnotation(Column.class); String columnName = field.getName(); if (anno != null && !anno.name().isEmpty()) { columnName = anno.name(); } Map<String, Object> recordValues = record.getValues(); String col = null; if (recordValues.containsKey(columnName)) { col = columnName; } else if (recordValues.containsKey("_" + columnName)) { col = "_" + columnName; } if (col != null) { Object value = record.getValueByKey(col); setFieldValue(pojo, field, value); } } currentClazz = currentClazz.getSuperclass(); } return pojo; } catch (Exception e) { throw new InfluxException(e); } }  @Nonnull T toPOJO(@Nonnull final FluxRecord record, @Nonnull final Class<T> clazz);  }