Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow to figure out, whether the Point.Builder has any fields #434

Merged
merged 1 commit into from
Mar 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/main/java/org/influxdb/dto/Point.java
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,15 @@ public Builder time(final long timeToSet, final TimeUnit precisionToSet) {
return this;
}

/**
* Does this builder contain any fields?
*
* @return true, if the builder contains any fields, false otherwise.
*/
public boolean hasFields() {
return !fields.isEmpty();
}

/**
* Create a new Point.
*
Expand Down
9 changes: 9 additions & 0 deletions src/test/java/org/influxdb/dto/PointTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -330,4 +330,13 @@ public void testUnEquals() throws Exception {
// THEN equals returns true
assertThat(equals).isEqualTo(false);
}

@Test
public void testBuilderHasFields() {
Point.Builder pointBuilder = Point.measurement("nulltest").time(1, TimeUnit.NANOSECONDS).tag("foo", "bar");
assertThat(pointBuilder.hasFields()).isFalse();

pointBuilder.addField("testfield", 256);
assertThat(pointBuilder.hasFields()).isTrue();
}
}