Class FieldTypeConflictHandler

java.lang.Object
io.openems.backend.timedata.influx.FieldTypeConflictHandler

public class FieldTypeConflictHandler extends Object
Handles Influx FieldTypeConflictExceptions. This helper provides conversion functions to provide the correct field types for InfluxDB.
  • Constructor Details

    • FieldTypeConflictHandler

      public FieldTypeConflictHandler(TimedataInfluxDb parent)
  • Method Details

    • handleException

      public void handleException(com.influxdb.exceptions.InfluxException e) throws IllegalStateException, IllegalArgumentException
      Handles a
      invalid reference
      FieldTypeConflictException
      ; adds special handling for fields that already exist in the database.
      Parameters:
      e - the
      invalid reference
      FieldTypeConflictException
      Throws:
      IllegalStateException
      IllegalArgumentException
    • handleExceptionMessage

      protected boolean handleExceptionMessage(String message) throws IllegalStateException, IllegalArgumentException
      Throws:
      IllegalStateException
      IllegalArgumentException
    • createHandler

      protected BiConsumer<com.influxdb.client.write.Point,com.google.gson.JsonElement> createHandler(String field, io.openems.backend.timedata.influx.FieldTypeConflictHandler.RequiredType requiredType)
      Creates a Handler for the given field, to convert a Point to a 'requiredType'.
      Parameters:
      field - the field name, i.e. the Channel-Address
      requiredType - the FieldTypeConflictHandler.RequiredType
      Returns:
      the Handler
    • getAsFieldTypeString

      protected static String getAsFieldTypeString(com.google.gson.JsonElement jValue)
      Convert JsonElement to String.
      Parameters:
      jValue - the value
      Returns:
      the value as String; null if value represents null
    • getAsFieldTypeLong

      protected static Long getAsFieldTypeLong(com.google.gson.JsonElement jValue)
      Convert JsonElement to Long.
      Parameters:
      jValue - the value
      Returns:
      the value as Long; null if value represents null
    • getAsFieldTypeDouble

      protected static Double getAsFieldTypeDouble(com.google.gson.JsonElement jValue)
      Convert JsonElement to Double.
      Parameters:
      jValue - the value
      Returns:
      the value as Double; null if value represents null
    • getHandler

      public BiConsumer<com.influxdb.client.write.Point,com.google.gson.JsonElement> getHandler(String field)
      Gets the handler for the given Field.
      Parameters:
      field - the Field
      Returns:
      the handler or null