Class Point

java.lang.Object
com.influxdb.v3.client.Point

@NotThreadSafe public final class Point extends Object
Point defines the values that will be written to the database. See Go Implementation.
Author:
Jakub Bednar (bednar@github) (11/10/2018 11:40)
  • Constructor Details

    • Point

      public Point(@Nonnull String measurementName)
      Create a new Point.
      Parameters:
      measurementName - the measurement name
  • Method Details

    • measurement

      @Nonnull public static Point measurement(@Nonnull String measurementName)
      Create a new Point withe specified a measurement name.
      Parameters:
      measurementName - the measurement name
      Returns:
      new instance of Point
    • fromValues

      public static Point fromValues(PointValues values) throws Exception
      Create a new Point with given values.
      Parameters:
      values - the point values
      Returns:
      the new Point
      Throws:
      Exception - if measurement is missing
    • getMeasurement

      @Nonnull public String getMeasurement()
      Get measurement name.
      Returns:
      Measurement name
    • setMeasurement

      @Nonnull public Point setMeasurement(@Nonnull String measurement)
      Updates the measurement for the point.
      Parameters:
      measurement - the measurement
      Returns:
      this
    • getTimestamp

      @Nullable public Number getTimestamp()
      Get timestamp. Can be null if not set.
      Returns:
      timestamp or null
    • setTimestamp

      @Nonnull public Point setTimestamp(@Nullable Instant time)
      Updates the timestamp for the point.
      Parameters:
      time - the timestamp
      Returns:
      this
    • setTimestamp

      @Nonnull public Point setTimestamp(@Nullable Number time, @Nonnull WritePrecision precision)
      Updates the timestamp for the point.
      Parameters:
      time - the timestamp
      precision - the timestamp precision
      Returns:
      this
    • setTimestamp

      @Nonnull public Point setTimestamp(@Nullable Long time, @Nonnull WritePrecision precision)
      Updates the timestamp for the point.
      Parameters:
      time - the timestamp
      precision - the timestamp precision
      Returns:
      this
    • getTag

      @Nullable public String getTag(@Nonnull String name)
      Gets value of tag with given name. Returns null if tag not found.
      Parameters:
      name - the tag name
      Returns:
      tag value or null
    • setTag

      @Nonnull public Point setTag(@Nonnull String key, @Nullable String value)
      Adds or replaces a tag value for this point.
      Parameters:
      key - the tag name
      value - the tag value
      Returns:
      this
    • setTags

      @Nonnull public Point setTags(@Nonnull Map<String,String> tagsToAdd)
      Adds or replaces tags for this point.
      Parameters:
      tagsToAdd - the Map of tags to add
      Returns:
      this
    • removeTag

      @Nonnull public Point removeTag(@Nonnull String name)
      Removes a tag with the specified name if it exists; otherwise, it does nothing.
      Parameters:
      name - the tag name
      Returns:
      this
    • getTagNames

      @Nonnull public String[] getTagNames()
      Gets an array of tag names.
      Returns:
      An array of tag names
    • getFloatField

      @Nullable public Double getFloatField(@Nonnull String name) throws ClassCastException
      Gets the float field value associated with the specified name. If the field is not present, returns null.
      Parameters:
      name - the field name
      Returns:
      The float field value or null
      Throws:
      ClassCastException
    • setFloatField

      @Nonnull public Point setFloatField(@Nonnull String name, double value)
      Adds or replaces a float field.
      Parameters:
      name - the field name
      value - the field value
      Returns:
      this
    • getIntegerField

      @Nullable public Long getIntegerField(@Nonnull String name) throws ClassCastException
      Gets the integer field value associated with the specified name. If the field is not present, returns null.
      Parameters:
      name - the field name
      Returns:
      The integer field value or null
      Throws:
      ClassCastException
    • setIntegerField

      public Point setIntegerField(@Nonnull String name, long value)
      Adds or replaces a integer field.
      Parameters:
      name - the field name
      value - the field value
      Returns:
      this
    • getStringField

      @Nullable public String getStringField(@Nonnull String name) throws ClassCastException
      Gets the string field value associated with the specified name. If the field is not present, returns null.
      Parameters:
      name - the field name
      Returns:
      The string field value or null
      Throws:
      ClassCastException
    • setStringField

      public Point setStringField(@Nonnull String name, String value)
      Adds or replaces a string field.
      Parameters:
      name - the field name
      value - the field value
      Returns:
      this
    • getBooleanField

      @Nullable public Boolean getBooleanField(@Nonnull String name) throws ClassCastException
      Gets the boolean field value associated with the specified name. If the field is not present, returns null.
      Parameters:
      name - the field name
      Returns:
      The boolean field value or null
      Throws:
      ClassCastException
    • setBooleanField

      public Point setBooleanField(@Nonnull String name, boolean value)
      Adds or replaces a boolean field.
      Parameters:
      name - the field name
      value - the field value
      Returns:
      this
    • getField

      @Nullable public Object getField(@Nonnull String name)
      Get field of given name. Can be null if field doesn't exist.
      Parameters:
      name - the field name
      Returns:
      Field as object
    • getField

      @Nullable public <T> T getField(String name, Class<T> type) throws ClassCastException
      Get field of given name as type. Can be null if field doesn't exist.
      Type Parameters:
      T - the field type
      Parameters:
      name - the field name
      type - the field type Class
      Returns:
      Field as given type
      Throws:
      ClassCastException
    • getFieldType

      @Nullable public Class<?> getFieldType(@Nonnull String name)
      Gets the type of field with given name, if it exists. If the field is not present, returns null.
      Parameters:
      name - the field name
      Returns:
      The field type or null.
    • setField

      @Nonnull public Point setField(@Nonnull String field, double value)
      Add Double field.
      Parameters:
      field - the field name
      value - the field value
      Returns:
      this
    • setField

      public Point setField(@Nonnull String field, long value)
      Add Long field.
      Parameters:
      field - the field name
      value - the field value
      Returns:
      this
    • setField

      @Nonnull public Point setField(@Nonnull String field, @Nullable Number value)
      Add Number field.
      Parameters:
      field - the field name
      value - the field value
      Returns:
      this
    • setField

      @Nonnull public Point setField(@Nonnull String field, @Nullable String value)
      Add String field.
      Parameters:
      field - the field name
      value - the field value
      Returns:
      this
    • setField

      @Nonnull public Point setField(@Nonnull String field, boolean value)
      Add Boolean field.
      Parameters:
      field - the field name
      value - the field value
      Returns:
      this
    • setField

      @Nonnull public Point setField(@Nonnull String field, @Nullable Object value)
      Add Object field.
      Parameters:
      field - the field name
      value - the field value
      Returns:
      this
    • setFields

      @Nonnull public Point setFields(@Nonnull Map<String,Object> fieldsToAdd)
      Adds or replaces fields for this point.
      Parameters:
      fieldsToAdd - the Map of fields to add
      Returns:
      this
    • removeField

      @Nonnull public Point removeField(@NonNull String name)
      Removes a field with the specified name if it exists; otherwise, it does nothing.
      Parameters:
      name - the field name
      Returns:
      this
    • getFieldNames

      @Nonnull public String[] getFieldNames()
      Gets an array of field names.
      Returns:
      An array of field names
    • hasFields

      public boolean hasFields()
      Has point any fields?
      Returns:
      true, if the point contains any fields, false otherwise.
    • copy

      @Nonnull public Point copy()
      Creates a copy of this object.
      Returns:
      A new instance with same values.
    • toLineProtocol

      @Nonnull public String toLineProtocol()
      Transform to Line Protocol with nanosecond precision.
      Returns:
      Line Protocol
    • toLineProtocol

      @Nonnull public String toLineProtocol(@Nullable WritePrecision precision)
      Transform to Line Protocol.
      Parameters:
      precision - required precision
      Returns:
      Line Protocol