public class APIHelper extends Object
| Modifier and Type | Field and Description |
|---|---|
static com.fasterxml.jackson.databind.ObjectMapper |
mapper |
| Constructor and Description |
|---|
APIHelper() |
| Modifier and Type | Method and Description |
|---|---|
static void |
appendUrlWithQueryParameters(StringBuilder queryBuilder,
Map<String,Object> parameters)
Appends the given set of parameters to the given query string
|
static void |
appendUrlWithTemplateParameters(StringBuilder queryBuilder,
Map<String,Object> parameters)
Replaces template parameters in the given url
|
static String |
cleanUrl(StringBuilder url)
Validates and processes the given Url
|
static String |
dateToString(Date date)
Convert a date to an ISO8601 formatted string
|
static LinkedHashMap<String,Object> |
deserialize(String json)
JSON Deserialization of the given json string.
|
static <T> T |
deserialize(String json,
Class<T> typeReference)
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 ExecutorService |
getScheduler()
Singleton access to the threadpool scheduler
|
static boolean |
isNullOrWhiteSpace(String s)
Validates if the string is null, empty or whitespace
|
static Date |
parseDate(String date)
Parse a date from its string representation
|
static void |
populate(String json,
APIException obj)
Populates an object of an APIException subclass with the required properties.
|
static Map<String,Object> |
prepareFormFields(Object value)
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 void |
replaceAll(StringBuilder stringBuilder,
String toReplace,
String replaceWith)
Replaces all occurrences of the given string in the string builder
|
static String |
serialize(Object obj)
JSON Serialization of a given object.
|
static void |
shutdown()
Shutdown all the threads
|
public static ExecutorService getScheduler()
public static void shutdown()
public static Date parseDate(String date)
date - ISO8601 encodede date stringpublic static String dateToString(Date date)
date - Date object to formatpublic static String serialize(Object obj) throws com.fasterxml.jackson.core.JsonProcessingException
obj - The object to serialize into JSONcom.fasterxml.jackson.core.JsonProcessingExceptionpublic static <T> T deserialize(String json, com.fasterxml.jackson.core.type.TypeReference<T> typeReference) throws IOException
T - The type of the object to deserialize intojson - The json string to deserializeIOExceptionpublic static <T> T deserialize(String json, Class<T> typeReference) throws IOException
T - The type of the object to deserialize intojParser - The json parser for reading json to deserializeIOExceptionpublic static void populate(String json, APIException obj) throws IOException
APIException - The object to populate.json - The json string to deserializeIOExceptionpublic static LinkedHashMap<String,Object> deserialize(String json) throws IOException
json - The json string to deserializeIOExceptionpublic static void appendUrlWithTemplateParameters(StringBuilder queryBuilder, Map<String,Object> parameters)
queryBuilder - The query string builder to replace the template parametersparameters - The parameters to replace in the urlpublic static void appendUrlWithQueryParameters(StringBuilder queryBuilder, Map<String,Object> parameters)
queryBuilder - The query url string to append the parametersparameters - The parameters to appendpublic static boolean isNullOrWhiteSpace(String s)
s - The string to validatepublic static void replaceAll(StringBuilder stringBuilder, String toReplace, String replaceWith)
stringBuilder - The string builder to update with replaced stringstoReplace - The string to replace in the string builderreplaceWith - The string to replace withpublic static void removeNullValues(Map<String,?> map)
public static String cleanUrl(StringBuilder url)
url - The given Url to processCopyright © 2017. All rights reserved.