Class PointValues

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

@NotThreadSafe public final class PointValues extends Object
PointValues 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

    • PointValues

      public PointValues()
      Create a new PointValues.
  • Method Details

    • measurement

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

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

      @Nonnull public PointValues 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 PointValues setTimestamp(@Nullable Instant time)
      Updates the timestamp for the point.
      Parameters:
      time - the timestamp
      Returns:
      this
    • setTimestamp

      @Nonnull public PointValues 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 PointValues 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 PointValues 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 PointValues 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 PointValues 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 PointValues 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 PointValues 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 PointValues 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 PointValues 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 PointValues setField(@Nonnull String field, double value)
      Add Double field.
      Parameters:
      field - the field name
      value - the field value
      Returns:
      this
    • setField

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

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

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

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

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

      @Nonnull public PointValues 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 PointValues 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 PointValues copy()
      Creates a copy of this object.
      Returns:
      A new instance with same values.
    • asPoint

      @Nonnull public Point asPoint(@Nonnull String measurement)
      Creates new Point with this as values with given measurement.
      Parameters:
      measurement - the point measurement
      Returns:
      Point from this values with given measurement.
    • asPoint

      @Nonnull public Point asPoint() throws Exception
      Creates new Point with this as values.
      Returns:
      Point from this values with given measurement.
      Throws:
      Exception - if measurement is missing