Class FieldTypeConflictHandler
java.lang.Object
io.openems.backend.timedata.influx.FieldTypeConflictHandler
Handles Influx FieldTypeConflictExceptions. This helper provides conversion
functions to provide the correct field types for InfluxDB.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected 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'.protected static Double
getAsFieldTypeDouble
(com.google.gson.JsonElement jValue) Convert JsonElement to Double.protected static Long
getAsFieldTypeLong
(com.google.gson.JsonElement jValue) Convert JsonElement to Long.protected static String
getAsFieldTypeString
(com.google.gson.JsonElement jValue) Convert JsonElement to String.BiConsumer
<com.influxdb.client.write.Point, com.google.gson.JsonElement> getHandler
(String field) Gets the handler for the given Field.void
handleException
(com.influxdb.exceptions.InfluxException e) Handles ainvalid reference
FieldTypeConflictException
protected boolean
handleExceptionMessage
(String message)
-
Constructor Details
-
FieldTypeConflictHandler
-
-
Method Details
-
handleException
public void handleException(com.influxdb.exceptions.InfluxException e) throws IllegalStateException, IllegalArgumentException Handles ainvalid reference
FieldTypeConflictException
- Parameters:
e
- theinvalid reference
FieldTypeConflictException
- Throws:
IllegalStateException
IllegalArgumentException
-
handleExceptionMessage
protected boolean handleExceptionMessage(String message) 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-AddressrequiredType
- theFieldTypeConflictHandler.RequiredType
- Returns:
- the Handler
-
getAsFieldTypeString
Convert JsonElement to String.- Parameters:
jValue
- the value- Returns:
- the value as String; null if value represents null
-
getAsFieldTypeLong
Convert JsonElement to Long.- Parameters:
jValue
- the value- Returns:
- the value as Long; null if value represents null
-
getAsFieldTypeDouble
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
-