public class CoreHelper extends Object
| Modifier | Constructor and Description |
|---|---|
protected |
CoreHelper() |
| Modifier and Type | Method and Description |
|---|---|
static void |
appendUrlWithQueryParameters(StringBuilder queryBuilder,
Map<String,Object> parameters,
io.apimatic.coreinterfaces.http.request.ArraySerializationFormat arraySerializationFormat)
Appends the given set of parameters to the given query string.
|
static void |
appendUrlWithTemplateParameters(StringBuilder queryBuilder,
Map<String,AbstractMap.SimpleEntry<Object,Boolean>> parameters)
Replaces template parameters in the given URL.
|
static String |
cleanUrl(StringBuilder url)
Validates and processes the given URL.
|
static <T> T |
deserialize(com.fasterxml.jackson.databind.JsonNode jsonNode,
Class<T> clazz)
JSON deserialization of the given JsonNode with FAIL_ON_UNKNOWN_PROPERTIES
flag as true.
|
static <T> T |
deserialize(com.fasterxml.jackson.databind.JsonNode json,
List<Class<? extends T>> classes,
boolean isOneOf)
Strict JSON deserialization of the given JSON string with
FAIL_ON_UNKNOWN_PROPERTIES flag as true, used particularly for type
combinators.
|
static <T> T |
deserialize(com.fasterxml.jackson.databind.JsonNode jsonNode,
com.fasterxml.jackson.core.type.TypeReference<T> typeReference)
JSON Deserialization of the given json string with FAIL_ON_UNKNOWN_PROPERTIES
flag as true.
|
static <T1,T2> T1 |
deserialize(com.fasterxml.jackson.databind.JsonNode jsonNode,
com.fasterxml.jackson.core.type.TypeReference<T1> typeReference,
Class<T2> cls,
com.fasterxml.jackson.databind.JsonDeserializer<T2> deserializer)
Json deserialization of the given Json string using a specified
JsonDerializer.
|
static <T> T |
deserialize(com.fasterxml.jackson.core.JsonParser jp,
com.fasterxml.jackson.databind.DeserializationContext ctxt,
String discriminator,
List<Map<String,Class<? extends T>>> registry,
List<Class<? extends T>> typesWithoutDiscriminator,
boolean isOneOf)
JSON Deserialization from custom deserializer based on given discriminator
and registry.
|
static LinkedHashMap<String,Object> |
deserialize(String json)
Json deserialization of the given Json string.
|
static <T> T |
deserialize(String json,
Class<T> clazz)
Json deserialization of the given Json string.
|
static <T> T |
deserialize(String json,
com.fasterxml.jackson.core.type.TypeReference<T> typeReference)
JSON Deserialization of the given json string.
|
static <T1,T2> T1 |
deserialize(String json,
com.fasterxml.jackson.core.type.TypeReference<T1> typeReference,
Class<T2> cls,
com.fasterxml.jackson.databind.JsonDeserializer<T2> deserializer)
Json deserialization of the given Json string using a specified
JsonDerializer.
|
static <T> List<T> |
deserializeArray(com.fasterxml.jackson.databind.JsonNode json,
Class<T[]> classArray)
JSON Deserialization of the given json string with FAIL_ON_UNKNOWN_PROPERTIES
flag as true.
|
static <T> List<T> |
deserializeArray(String json,
Class<T[]> classArray)
JSON Deserialization of the given json string.
|
static Object |
deserializeAsObject(String json)
Json deserialization of the given Json string.
|
static <T> T |
deserializeXml(String xml,
Class<T> cls)
XML Deserialization of the given xml string.
|
static <T> List<T> |
deserializeXmlArray(String xml,
Class<T[]> cls)
XML Deserialization of the given xml string.
|
static <T> List<T> |
deserializeXmlSimpleTypesArray(String xml,
Class<T> cls)
XML Deserialization of the given xml string for simple types.
|
static String |
getBase64EncodedCredentials(String basicAuthUserName,
String basicAuthPassword)
Responsible to encode into base64 the username and password
|
static com.fasterxml.jackson.databind.ObjectMapper |
getMapper()
Deserialization of Json data.
|
static Map<String,Object> |
getQueryParameters(String queryUrl)
Extracts query parameters from a given URL into a map.
|
static String |
getQueryParametersFromUrl(String queryUrl)
Returns query parameters from url
|
static com.fasterxml.jackson.databind.ObjectMapper |
getStrictMapper()
Strict Deserialization of Json data.
|
static String |
getValueFromJson(String pointer,
String json)
Retrieves a value from a JSON string using a JSON pointer.
|
static boolean |
isNullOrWhiteSpace(String s)
Validates if the string is null, empty or whitespace.
|
static boolean |
isTypeCombinatorDateTimeCase(Object obj)
Check either the object has TypeCombinatorDateTimeCase annotation.
|
static boolean |
isTypeCombinatorStringCase(Object obj)
Check either the object has TypeCombinatorStringCase annotation.
|
static List<AbstractMap.SimpleEntry<String,Object>> |
prepareFormFields(Map<?,?> value,
io.apimatic.coreinterfaces.http.request.ArraySerializationFormat arraySerializationFormat)
Prepares Array style form fields from a given array of values.
|
static void |
removeNullValues(Map<String,?> map)
Removes null values from the given map.
|
static String |
removeQueryParametersFromUrl(String queryUrl)
Returns Url without query parameters
|
static void |
replaceAll(StringBuilder stringBuilder,
String toReplace,
String replaceWith)
Replaces all occurrences of the given string in the string builder.
|
static String |
resolveResponsePointer(String pointer,
io.apimatic.coreinterfaces.http.response.Response response)
Resolves a pointer within a JSON response body or headers.
|
static String |
serialize(Object obj)
Json Serialization of a given object.
|
static String |
serialize(Object obj,
com.fasterxml.jackson.databind.JsonSerializer serializer)
Json Serialization of a given object using a specified JsonSerializer.
|
static String |
serializeEnumContainer(Object value)
Json Serialization of an ENUM defined under oneOf/anyOf container.
|
static String |
serializeTypeCombinator(Object obj)
Json Serialization of a given container object based on annotation.
|
static <T> String |
serializeXml(T obj,
String rootName,
Class<T> cls)
Xml Serialization of a given object.
|
static <T> String |
serializeXmlArray(T[] objArray,
String rootName,
String nodeName,
Class<T> cls)
Xml Serialization of a given object list.
|
static <T> T |
tryDeserialize(String json,
Class<T> clazz)
Json deserialization of the given Json string.
|
static String |
trySerialize(Object obj)
Json Serialization of a given object.
|
static String |
tryUrlDecode(String value)
Tries URL decoding using UTF-8.
|
static String |
tryUrlEncode(String value,
boolean spaceAsPercentEncoded)
Tries URL encode using UTF-8.
|
static String |
updateUserAgent(String apiUserAgent,
Map<String,String> userAgentConfig)
Updates the user agent header value.
|
static <T> T |
updateValueByPointer(T value,
String pointer,
java.util.function.UnaryOperator<Object> updater)
Updates the value of an object by a JSON pointer using the provided updater function.
|
public static com.fasterxml.jackson.databind.ObjectMapper getMapper()
ObjectMapper.public static com.fasterxml.jackson.databind.ObjectMapper getStrictMapper()
ObjectMapper.public static String serialize(Object obj) throws com.fasterxml.jackson.core.JsonProcessingException
obj - The object to serialize into Json.com.fasterxml.jackson.core.JsonProcessingException - Signals that a Json Processing Exception has
occurred.public static String trySerialize(Object obj)
obj - The object to serialize into Json.public static String serialize(Object obj, com.fasterxml.jackson.databind.JsonSerializer serializer) throws com.fasterxml.jackson.core.JsonProcessingException
obj - The object to serialize into Json.serializer - The instance of JsonSerializer to use.com.fasterxml.jackson.core.JsonProcessingException - Signals that a Json Processing Exception has
occurred.public static <T> String serializeXmlArray(T[] objArray, String rootName, String nodeName, Class<T> cls) throws IOException
T - Type of object to be serialized.objArray - Object Array to be serialized.rootName - Root name for the xml.nodeName - Node name for the array nodes.cls - Class of object to be serialized.IOException - Signals that an IO exception occurred.public static <T> String serializeXml(T obj, String rootName, Class<T> cls) throws IOException
T - Type of object to be serialized.obj - Object to be serialized.rootName - Root name for the xml.cls - Class of object to be serialized.IOException - Signals that an IOException exception occurred.public static String serializeTypeCombinator(Object obj) throws com.fasterxml.jackson.core.JsonProcessingException
obj - The object to serialize into Json.com.fasterxml.jackson.core.JsonProcessingException - Signals that a Json Processing Exception has
occurred.public static boolean isTypeCombinatorStringCase(Object obj)
obj - The object to check annotation.public static boolean isTypeCombinatorDateTimeCase(Object obj)
obj - The object to check annotation.public static <T1,T2> T1 deserialize(com.fasterxml.jackson.databind.JsonNode jsonNode,
com.fasterxml.jackson.core.type.TypeReference<T1> typeReference,
Class<T2> cls,
com.fasterxml.jackson.databind.JsonDeserializer<T2> deserializer)
throws IOException
T1 - The type of the object to deserialize into.T2 - The type of the custom deserializer.jsonNode - The JsonNode to deserialize.typeReference - TypeReference of T1.cls - The class to attach the deserializer to.deserializer - The deserializer to use.IOException - Signals if any I/O exception occurred.public static <T1,T2> T1 deserialize(String json, com.fasterxml.jackson.core.type.TypeReference<T1> typeReference, Class<T2> cls, com.fasterxml.jackson.databind.JsonDeserializer<T2> deserializer) throws IOException
T1 - The type of the object to deserialize into.T2 - The type of the custom deserializer.json - The Json string to deserialize.typeReference - TypeReference of T1.cls - The class to attach the deserializer to.deserializer - The deserializer to use.IOException - Signals if any I/O exception occurred.public static <T> T deserialize(String json, Class<T> clazz) throws IOException
T - The type of the object to deserialize into.json - The Json string to deserialize.clazz - The type of the object to deserialize into.IOException - Signals if any I/O exception occurred.public static <T> T tryDeserialize(String json, Class<T> clazz)
T - The type of the object to deserialize into.json - The Json string to deserialize.clazz - The type of the object to deserialize into.public static <T> T deserialize(com.fasterxml.jackson.databind.JsonNode json,
List<Class<? extends T>> classes,
boolean isOneOf)
throws IOException
T - The type of the object to deserialize intojson - The JsonNode to deserializeclasses - The list of types of the object to deserialize intoisOneOf - The boolean flag to validate for oneOf flowIOException - Signals if any I/O exception occurred.public static LinkedHashMap<String,Object> deserialize(String json) throws IOException
json - The Json string to deserialize.IOException - Signals if any I/O exception occurred.public static <T> T deserialize(String json, com.fasterxml.jackson.core.type.TypeReference<T> typeReference) throws IOException
T - The type of the object to deserialize into.json - The json string to deserialize.typeReference - TypeReference of T.IOException - Signals if any I/O exception occurred.public static <T> T deserialize(com.fasterxml.jackson.databind.JsonNode jsonNode,
com.fasterxml.jackson.core.type.TypeReference<T> typeReference)
throws IOException
T - The type of the object to deserialize into.jsonNode - The Json Node to deserialize.typeReference - TypeReference of T.IOException - Signals if any I/O exception occurred.public static <T> T deserialize(com.fasterxml.jackson.databind.JsonNode jsonNode,
Class<T> clazz)
throws IOException
T - The type of the object to deserialize into.jsonNode - The Json Node to deserialize.clazz - The type of the object to deserialize into.IOException - Signals if any I/O exception occurred.public static <T> T deserializeXml(String xml, Class<T> cls) throws IOException
T - The class of the object to deserialize into.xml - The xml string to deserialize.cls - The class of the object to deserialize into.IOException - Signals if any I/O exception occurred.public static <T> List<T> deserializeXmlArray(String xml, Class<T[]> cls) throws IOException
T - The class of the object to deserialize into.xml - The xml string to deserialize.cls - The class of the object to deserialize into.IOException - Signals if any I/O exception occurred.public static <T> List<T> deserializeXmlSimpleTypesArray(String xml, Class<T> cls) throws IOException
T - The class of the object to deserialize into.xml - The xml string to deserialize.cls - The class of the object to deserialize into.IOException - Signals if any I/O exception occurred.public static <T> T deserialize(com.fasterxml.jackson.core.JsonParser jp,
com.fasterxml.jackson.databind.DeserializationContext ctxt,
String discriminator,
List<Map<String,Class<? extends T>>> registry,
List<Class<? extends T>> typesWithoutDiscriminator,
boolean isOneOf)
throws IOException
T - the deserialized response type.jp - Parsed used for reading JSON content.ctxt - Context that can be used to access
information about this deserialization
activity.discriminator - The model's discriminator.registry - The map containing all discriminators as
keys and associated classes as values.typesWithoutDiscriminator - The list containing all types without
discriminators.isOneOf - The boolean flag to validate for oneOf flow.IOException - Signals if any I/O exception occurred.public static Object deserializeAsObject(String json)
json - The Json string to deserialize.public static <T> List<T> deserializeArray(String json, Class<T[]> classArray) throws IOException
T - The type of the object to deserialize into.json - The Json string to deserialize.classArray - The class of the array of objects to deserialize into.IOException - Signals if any I/O exception occurred..public static void appendUrlWithTemplateParameters(StringBuilder queryBuilder, Map<String,AbstractMap.SimpleEntry<Object,Boolean>> parameters)
queryBuilder - The query string builder to replace the template
parameters.parameters - The parameters to replace in the URL.public static void appendUrlWithQueryParameters(StringBuilder queryBuilder, Map<String,Object> parameters, io.apimatic.coreinterfaces.http.request.ArraySerializationFormat arraySerializationFormat)
queryBuilder - The query URL string to append the
parameters.parameters - The parameters to append.arraySerializationFormat - the array serialization format.public static boolean isNullOrWhiteSpace(String s)
s - The string to validate.public static void replaceAll(StringBuilder stringBuilder, String toReplace, String replaceWith)
stringBuilder - The string builder to update with replaced strings.toReplace - The string to replace in the string builder.replaceWith - The string to replace with.public static String updateUserAgent(String apiUserAgent, Map<String,String> userAgentConfig)
apiUserAgent - the String value of apiUserAgent.userAgentConfig - the Map of user agent config.String.public static void removeNullValues(Map<String,?> map)
map - Map of values.public static String cleanUrl(StringBuilder url)
url - The given URL to process.public static List<AbstractMap.SimpleEntry<String,Object>> prepareFormFields(Map<?,?> value, io.apimatic.coreinterfaces.http.request.ArraySerializationFormat arraySerializationFormat)
value - Value for the form fields.arraySerializationFormat - serialization format.public static <T> List<T> deserializeArray(com.fasterxml.jackson.databind.JsonNode json, Class<T[]> classArray) throws IOException
T - The type of the object to deserialize into.json - The Json string to deserialize.classArray - The class of the array of objects to deserialize into.IOException - Signals if any I/O exception occurred.public static String tryUrlEncode(String value, boolean spaceAsPercentEncoded)
value - The value to URL encode.spaceAsPercentEncoded - The flag get space character as percent encoded.public static String tryUrlDecode(String value)
value - The value to decode.public static String getBase64EncodedCredentials(String basicAuthUserName, String basicAuthPassword)
basicAuthUserName - The auth usernamebasicAuthPassword - The auth passwordpublic static String serializeEnumContainer(Object value) throws com.fasterxml.jackson.core.JsonProcessingException
value - The object to serialize into Json String.com.fasterxml.jackson.core.JsonProcessingException - Signals that a Json Processing Exception has
occurred.public static String removeQueryParametersFromUrl(String queryUrl)
queryUrl - Url to remove query parameters from.public static String getQueryParametersFromUrl(String queryUrl)
queryUrl - Url to get query parameters from.public static Map<String,Object> getQueryParameters(String queryUrl)
queryUrl - The URL containing query parameters.public static String resolveResponsePointer(String pointer, io.apimatic.coreinterfaces.http.response.Response response)
pointer - The JSON pointer.response - The response.public static String getValueFromJson(String pointer, String json)
pointer - The pointer path.json - The JSON string.public static <T> T updateValueByPointer(T value,
String pointer,
java.util.function.UnaryOperator<Object> updater)
T - The type of the object.value - The object to update.pointer - The JSON pointer.updater - The function to apply to the value at the pointer.Copyright © 2025. All rights reserved.