Class JsonConfigObjectMapper

java.lang.Object
com.seeq.link.sdk.services.JsonConfigObjectMapper

public class JsonConfigObjectMapper extends Object
  • 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 IOException
      Converts a json into a ConfigObject and wraps it into a ConfigObjectWrapper. 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 convert
      defaultConfigObjects - 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 resulting ConfigObjectWrapper
      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 a MyConfig<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