Skip to content

Commit 89dc759

Browse files
MelulekiDubefmachado
authored andcommitted
Now Point.Builder.addFieldsFromPOJO adds Column fields from super classes (#617)
* Now add POJO adds Column fields from inherited classes * Added white space after while loop declaration * Added white space before loop * prefixed all added '{' with whitespaces * Update CHANGELOG.md
1 parent e20f5b4 commit 89dc759

File tree

3 files changed

+661
-627
lines changed

3 files changed

+661
-627
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ OkHttpClient client = new OkHttpClient.Builder()
3131
[Issue #367](https://github.com/influxdata/influxdb-java/issues/367)
3232
- BatchOptions to have .precision()
3333
[Issue #532](https://github.com/influxdata/influxdb-java/issues/532)
34+
- Point.Builder.addFieldsFromPOJO to add Column fields from super class
35+
[Issue #613](https://github.com/influxdata/influxdb-java/issues/613)
3436

3537
## 2.14 [2018-10-12]
3638

src/main/java/org/influxdb/dto/Point.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -235,19 +235,22 @@ public boolean hasFields() {
235235
public Builder addFieldsFromPOJO(final Object pojo) {
236236

237237
Class<? extends Object> clazz = pojo.getClass();
238+
while (clazz != null) {
238239

239-
for (Field field : clazz.getDeclaredFields()) {
240+
for (Field field : clazz.getDeclaredFields()) {
240241

241-
Column column = field.getAnnotation(Column.class);
242+
Column column = field.getAnnotation(Column.class);
242243

243-
if (column == null) {
244-
continue;
245-
}
244+
if (column == null) {
245+
continue;
246+
}
246247

247-
field.setAccessible(true);
248-
String fieldName = column.name();
249-
addFieldByAttribute(pojo, field, column, fieldName);
250-
}
248+
field.setAccessible(true);
249+
String fieldName = column.name();
250+
addFieldByAttribute(pojo, field, column, fieldName);
251+
}
252+
clazz = clazz.getSuperclass();
253+
}
251254

252255
if (this.fields.isEmpty()) {
253256
throw new BuilderException("Class " + pojo.getClass().getName()

0 commit comments

Comments
 (0)