Package com.atlan.util
Class JacksonUtils
java.lang.Object
com.atlan.util.JacksonUtils
Utilities for interacting with Jackson for serialization and deserialization.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic BooleandeserializeBoolean(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 DoubledeserializeDouble(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 LongdeserializeLong(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 ObjectdeserializeNumber(com.fasterxml.jackson.databind.JsonNode primitive, Method method) Deserialize a number direct to an object, converting to the correct type.static <T> TdeserializeObject(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 <T> TdeserializeObject(AtlanClient client, com.fasterxml.jackson.databind.JsonNode node, String path, Class<T> type) Deserialize the provided path into a full object, or null if there is no value at the path.static ObjectdeserializePrimitive(com.fasterxml.jackson.databind.JsonNode primitive, Method method) Deserialize a primitive JSON value to an object.static ObjectdeserializePrimitive(com.fasterxml.jackson.databind.JsonNode primitive, Method method, Class<?> singularClass) Deserialize a primitive JSON value to an object.static StringdeserializeString(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 voidserializeBoolean(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 voidserializeDouble(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 voidserializeLong(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 voidserializeObject(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 voidserializeString(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.
-
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 deserializemethod- 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 typeIllegalAccessExceptionInvocationTargetExceptionNoSuchMethodException
-
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 deserializemethod- through which the deserialized value will be set on the objectsingularClass- 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 typeIllegalAccessExceptionInvocationTargetExceptionNoSuchMethodException
-
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 deserializemethod- 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
Deserialize the provided path into a string, or null if there is no value at the path.- Parameters:
node- from which to pull the valuepath- 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 serializename- of the fieldvalue- for the field- Throws:
IOException- on any issues writing to the generator
-
deserializeLong
Deserialize the provided path into a long, or null if there is no value at the path.- Parameters:
node- from which to pull the valuepath- 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 serializename- of the fieldvalue- for the field- Throws:
IOException- on any issues writing to the generator
-
deserializeDouble
Deserialize the provided path into a double, or null if there is no value at the path.- Parameters:
node- from which to pull the valuepath- 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 serializename- of the fieldvalue- for the field- Throws:
IOException- on any issues writing to the generator
-
deserializeBoolean
Deserialize the provided path into a boolean, or null if there is no value at the path.- Parameters:
node- from which to pull the valuepath- 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 serializename- of the fieldvalue- 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 Atlannode- from which to pull the valuepath- at which to find the valuetypeReference- of the expected value- Returns:
- the object value, or null
- Throws:
com.fasterxml.jackson.core.JsonProcessingException- on any problems parsing the expected value
-
deserializeObject
public static <T> T deserializeObject(AtlanClient client, com.fasterxml.jackson.databind.JsonNode node, String path, Class<T> type) 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 Atlannode- from which to pull the valuepath- at which to find the valuetype- 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 serializename- of the fieldvalue- for the field- Throws:
IOException- on any issues writing to the generator
-