Class JacksonUtils

java.lang.Object
com.atlan.util.JacksonUtils

public class JacksonUtils extends Object
Utilities for interacting with Jackson for serialization and deserialization.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static Boolean
    deserializeBoolean(com.fasterxml.jackson.databind.JsonNode node, String path)
    Deserialize the provided path into a boolean, or null if there is no value at the path.
    static Double
    deserializeDouble(com.fasterxml.jackson.databind.JsonNode node, String path)
    Deserialize the provided path into a double, or null if there is no value at the path.
    static Long
    deserializeLong(com.fasterxml.jackson.databind.JsonNode node, String path)
    Deserialize the provided path into a long, or null if there is no value at the path.
    static Object
    deserializeNumber(com.fasterxml.jackson.databind.JsonNode primitive, Method method)
    Deserialize a number direct to an object, converting to the correct type.
    static <T> T
    deserializeObject(AtlanClient client, com.fasterxml.jackson.databind.JsonNode node, String path, com.fasterxml.jackson.core.type.TypeReference<T> typeReference)
    Deserialize the provided path into a full object, or null if there is no value at the path.
    static Object
    deserializePrimitive(com.fasterxml.jackson.databind.JsonNode primitive, Method method)
    Deserialize a primitive JSON value to an object.
    static Object
    deserializePrimitive(com.fasterxml.jackson.databind.JsonNode primitive, Method method, Class<?> singularClass)
    Deserialize a primitive JSON value to an object.
    static String
    deserializeString(com.fasterxml.jackson.databind.JsonNode node, String path)
    Deserialize the provided path into a string, or null if there is no value at the path.
    static void
    serializeBoolean(com.fasterxml.jackson.core.JsonGenerator gen, String name, Boolean value)
    Serialize the provided field into a boolean, or leave it out if there is no value.
    static void
    serializeDouble(com.fasterxml.jackson.core.JsonGenerator gen, String name, Double value)
    Serialize the provided field into a double, or leave it out if there is no value.
    static void
    serializeLong(com.fasterxml.jackson.core.JsonGenerator gen, String name, Long value)
    Serialize the provided field into a long, or leave it out if there is no value.
    static void
    serializeObject(com.fasterxml.jackson.core.JsonGenerator gen, String name, Object value)
    Serialize the provided field into an object, or leave it out if there is no value.
    static void
    serializeString(com.fasterxml.jackson.core.JsonGenerator gen, String name, String value)
    Serialize the provided field into a string, or leave it out if there is no value.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • JacksonUtils

      public JacksonUtils()
  • Method Details

    • deserializePrimitive

      public static Object deserializePrimitive(com.fasterxml.jackson.databind.JsonNode primitive, Method method) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException, IOException
      Deserialize a primitive JSON value to an object.
      Parameters:
      primitive - value to deserialize
      method - through which the deserialized value will be set on the object
      Returns:
      the deserialized value
      Throws:
      IOException - if the setter method to deserialize through does not take exactly one argument, or uses an unhandled numeric type
      IllegalAccessException
      InvocationTargetException
      NoSuchMethodException
    • deserializePrimitive

      public static Object deserializePrimitive(com.fasterxml.jackson.databind.JsonNode primitive, Method method, Class<?> singularClass) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException, IOException
      Deserialize a primitive JSON value to an object.
      Parameters:
      primitive - value to deserialize
      method - through which the deserialized value will be set on the object
      singularClass - class of the first argument (parameter) to the setter method, singularized
      Returns:
      the deserialized value
      Throws:
      IOException - if the setter method to deserialize through does not take exactly one argument, or uses an unhandled numeric type
      IllegalAccessException
      InvocationTargetException
      NoSuchMethodException
    • deserializeNumber

      public static Object deserializeNumber(com.fasterxml.jackson.databind.JsonNode primitive, Method method) throws IOException
      Deserialize a number direct to an object, converting to the correct type.
      Parameters:
      primitive - number to deserialize
      method - through which to the deserialized value will be set on the object
      Returns:
      the deserialized number
      Throws:
      IOException - if the setter method to deserialize through does not take exactly one argument, or uses an unhandled numeric type
    • deserializeString

      public static String deserializeString(com.fasterxml.jackson.databind.JsonNode node, String path)
      Deserialize the provided path into a string, or null if there is no value at the path.
      Parameters:
      node - from which to pull the value
      path - at which to find the value
      Returns:
      the string value, or null
    • serializeString

      public static void serializeString(com.fasterxml.jackson.core.JsonGenerator gen, String name, String value) throws IOException
      Serialize the provided field into a string, or leave it out if there is no value.
      Parameters:
      gen - generator through which to serialize
      name - of the field
      value - for the field
      Throws:
      IOException - on any issues writing to the generator
    • deserializeLong

      public static Long deserializeLong(com.fasterxml.jackson.databind.JsonNode node, String path)
      Deserialize the provided path into a long, or null if there is no value at the path.
      Parameters:
      node - from which to pull the value
      path - at which to find the value
      Returns:
      the long value, or null
    • serializeLong

      public static void serializeLong(com.fasterxml.jackson.core.JsonGenerator gen, String name, Long value) throws IOException
      Serialize the provided field into a long, or leave it out if there is no value.
      Parameters:
      gen - generator through which to serialize
      name - of the field
      value - for the field
      Throws:
      IOException - on any issues writing to the generator
    • deserializeDouble

      public static Double deserializeDouble(com.fasterxml.jackson.databind.JsonNode node, String path)
      Deserialize the provided path into a double, or null if there is no value at the path.
      Parameters:
      node - from which to pull the value
      path - at which to find the value
      Returns:
      the double value, or null
    • serializeDouble

      public static void serializeDouble(com.fasterxml.jackson.core.JsonGenerator gen, String name, Double value) throws IOException
      Serialize the provided field into a double, or leave it out if there is no value.
      Parameters:
      gen - generator through which to serialize
      name - of the field
      value - for the field
      Throws:
      IOException - on any issues writing to the generator
    • deserializeBoolean

      public static Boolean deserializeBoolean(com.fasterxml.jackson.databind.JsonNode node, String path)
      Deserialize the provided path into a boolean, or null if there is no value at the path.
      Parameters:
      node - from which to pull the value
      path - at which to find the value
      Returns:
      the boolean value, or null
    • serializeBoolean

      public static void serializeBoolean(com.fasterxml.jackson.core.JsonGenerator gen, String name, Boolean value) throws IOException
      Serialize the provided field into a boolean, or leave it out if there is no value.
      Parameters:
      gen - generator through which to serialize
      name - of the field
      value - for the field
      Throws:
      IOException - on any issues writing to the generator
    • deserializeObject

      public static <T> T deserializeObject(AtlanClient client, com.fasterxml.jackson.databind.JsonNode node, String path, com.fasterxml.jackson.core.type.TypeReference<T> typeReference) throws com.fasterxml.jackson.core.JsonProcessingException
      Deserialize the provided path into a full object, or null if there is no value at the path.
      Type Parameters:
      T - the type of the object's value
      Parameters:
      client - connectivity to Atlan
      node - from which to pull the value
      path - at which to find the value
      typeReference - of the expected value
      Returns:
      the object value, or null
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException - on any problems parsing the expected value
    • serializeObject

      public static void serializeObject(com.fasterxml.jackson.core.JsonGenerator gen, String name, Object value) throws IOException
      Serialize the provided field into an object, or leave it out if there is no value.
      Parameters:
      gen - generator through which to serialize
      name - of the field
      value - for the field
      Throws:
      IOException - on any issues writing to the generator