Package com.seeq.link.sdk.services
Class JsonConfigObjectMapper
java.lang.Object
com.seeq.link.sdk.services.JsonConfigObjectMapper
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
We have our own PascalCase naming strategy so that it matches .NET Link -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ConfigObjectWrapper
toConfigObjectWrapper
(String jsonString, ConfigObject[] defaultConfigObjects, String parseErrorMessage, Long lastModified) static ConfigObjectWrapper
toConfigObjectWrapper
(String jsonString, ConfigObject[] defaultConfigObjects, String parseErrorMessage, Long lastModified, Map<Class<? extends ConfigObject>, Class<?>[]> configObjectTypeArguments) Converts a json into aConfigObject
and wraps it into aConfigObjectWrapper
.static String
Converts a configObject into a json
-
Constructor Details
-
JsonConfigObjectMapper
public JsonConfigObjectMapper()
-
-
Method Details
-
toConfigObjectWrapper
public static ConfigObjectWrapper toConfigObjectWrapper(String jsonString, ConfigObject[] defaultConfigObjects, String parseErrorMessage, Long lastModified) throws IOException - Throws:
IOException
-
toConfigObjectWrapper
public static ConfigObjectWrapper toConfigObjectWrapper(String jsonString, ConfigObject[] defaultConfigObjects, String parseErrorMessage, Long lastModified, Map<Class<? extends ConfigObject>, Class<?>[]> configObjectTypeArguments) throws IOExceptionConverts a json into aConfigObject
and wraps it into aConfigObjectWrapper
. The wrapper provides additional information about the configuration (like last modified date). This function requires an array of config objects to use as a means of discovering what Object type is encoded in the store.- Parameters:
jsonString
- The json to convertdefaultConfigObjects
- An array of ConfigObject instances that represent the possible Object types that can be successfully retrieved from the store. If the persisted Object type does not match anything in the list, then the first item in the array is passed back (being effectively a means to have a 'default' config).parseErrorMessage
- Error message logged if json parsing fails.lastModified
- A nullable Long that will be set in the resultingConfigObjectWrapper
configObjectTypeArguments
- A mapping of ConfigObject types to an array of their type arguments; the array should be null or empty if the ConfigObject type is not generic. This is necessary for ConfigObjects of generic types to be deserialized correctly due to Java's generic type erasure. For example, when deserializing aMyConfig<MyPostgresSettings>
, configObjectTypeArguments should contain{ MyConfig.class : [ MyPostgresSettings.class ] }
.- Returns:
- The resulting configuration wrapper
- Throws:
IOException
- If the received string is not having a valid json format.
-
toJson
public static String toJson(Object configObject) throws com.fasterxml.jackson.core.JsonProcessingException Converts a configObject into a json- Parameters:
configObject
- The configuration object to be converted to json- Returns:
- The configuration object as json string
- Throws:
com.fasterxml.jackson.core.JsonProcessingException
-