Package io.jans.as.model.util
Class Util
- java.lang.Object
-
- io.jans.as.model.util.Util
-
public class Util extends java.lang.Object
- Version:
- September 4, 2019
- Author:
- Yuriy Zabrovarnyy, Javier Rojas Blum
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
PAR_ID_REFIX
static java.lang.String
PAR_ID_SHORT_REFIX
static java.lang.String
UTF8_STRING_ENCODING
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
addToJSONObjectIfNotNull(org.json.JSONObject jsonObject, java.lang.String key, io.jans.orm.annotation.AttributeEnum value)
static void
addToJSONObjectIfNotNull(org.json.JSONObject jsonObject, java.lang.String key, java.lang.Object value)
static void
addToJSONObjectIfNotNull(org.json.JSONObject jsonObject, java.lang.String key, java.lang.String[] value)
static void
addToListIfHas(java.util.List<java.lang.String> list, org.json.JSONObject jsonObj, java.lang.String key)
static boolean
allNotBlank(java.lang.String... strings)
static <T extends io.jans.orm.annotation.AttributeEnum>
java.util.List<T>asEnumList(org.json.JSONArray array, java.lang.Class<T> clazz)
static java.lang.String
asJson(java.lang.Object object)
static java.lang.String
asJsonSilently(java.lang.Object object)
static java.util.List<java.lang.String>
asList(org.json.JSONArray array)
static java.lang.String
asPrettyJson(java.lang.Object object)
static java.lang.String
asString(java.util.List<? extends HasParamName> list)
static java.lang.String
byteArrayToHexString(byte[] b)
static java.util.Date
createExpirationDate(java.lang.Integer lifetimeInSeconds)
static com.fasterxml.jackson.databind.ObjectMapper
createJsonMapper()
static java.lang.String
escapeLog(java.lang.Object param)
static <T> T
firstItem(java.util.List<T> items)
static byte[]
getBytes(java.lang.String str)
static java.lang.Integer
getNumberOfSecondFromNow(java.util.Date date)
static boolean
isNullOrEmpty(java.lang.String string)
static boolean
isPar(java.lang.String requestUri)
static java.util.List<java.lang.String>
jsonArrayStringAsList(java.lang.String jsonString)
static java.util.Map<java.lang.String,java.lang.String>
jsonObjectArrayStringAsMap(java.lang.String jsonString)
static java.lang.String
listAsString(java.util.List<java.lang.String> list)
static org.json.JSONArray
listToJsonArray(java.util.Collection<java.lang.String> list)
static java.lang.String
mapAsString(java.util.Map<java.lang.String,java.lang.String> map)
static int
parseIntSilently(java.lang.String intString)
static void
putNotBlank(java.util.Map map, java.lang.String key, java.lang.Object value)
static java.util.List<java.lang.String>
splittedStringAsList(java.lang.String string, java.lang.String delimiter)
static java.util.Map<java.lang.String,java.io.Serializable>
toSerializableMap(java.util.Map<java.lang.String,java.lang.Object> map)
static java.lang.String
toSHA1HexString(java.lang.String input)
-
-
-
Field Detail
-
UTF8_STRING_ENCODING
public static final java.lang.String UTF8_STRING_ENCODING
- See Also:
- Constant Field Values
-
PAR_ID_REFIX
public static final java.lang.String PAR_ID_REFIX
- See Also:
- Constant Field Values
-
PAR_ID_SHORT_REFIX
public static final java.lang.String PAR_ID_SHORT_REFIX
- See Also:
- Constant Field Values
-
-
Method Detail
-
putNotBlank
public static void putNotBlank(java.util.Map map, java.lang.String key, java.lang.Object value)
-
escapeLog
public static java.lang.String escapeLog(java.lang.Object param)
-
createJsonMapper
public static com.fasterxml.jackson.databind.ObjectMapper createJsonMapper()
-
asJsonSilently
public static java.lang.String asJsonSilently(java.lang.Object object)
-
asPrettyJson
public static java.lang.String asPrettyJson(java.lang.Object object) throws java.io.IOException
- Throws:
java.io.IOException
-
asJson
public static java.lang.String asJson(java.lang.Object object) throws java.io.IOException
- Throws:
java.io.IOException
-
getBytes
public static byte[] getBytes(java.lang.String str)
-
asList
public static java.util.List<java.lang.String> asList(org.json.JSONArray array) throws org.json.JSONException
- Throws:
org.json.JSONException
-
asEnumList
public static <T extends io.jans.orm.annotation.AttributeEnum> java.util.List<T> asEnumList(org.json.JSONArray array, java.lang.Class<T> clazz) throws org.json.JSONException, java.lang.NoSuchMethodException, java.lang.reflect.InvocationTargetException, java.lang.IllegalAccessException
- Throws:
org.json.JSONException
java.lang.NoSuchMethodException
java.lang.reflect.InvocationTargetException
java.lang.IllegalAccessException
-
addToListIfHas
public static void addToListIfHas(java.util.List<java.lang.String> list, org.json.JSONObject jsonObj, java.lang.String key) throws org.json.JSONException
- Throws:
org.json.JSONException
-
addToJSONObjectIfNotNull
public static void addToJSONObjectIfNotNull(org.json.JSONObject jsonObject, java.lang.String key, java.lang.Object value) throws org.json.JSONException
- Throws:
org.json.JSONException
-
addToJSONObjectIfNotNull
public static void addToJSONObjectIfNotNull(org.json.JSONObject jsonObject, java.lang.String key, io.jans.orm.annotation.AttributeEnum value) throws org.json.JSONException
- Throws:
org.json.JSONException
-
addToJSONObjectIfNotNull
public static void addToJSONObjectIfNotNull(org.json.JSONObject jsonObject, java.lang.String key, java.lang.String[] value) throws org.json.JSONException
- Throws:
org.json.JSONException
-
asString
public static java.lang.String asString(java.util.List<? extends HasParamName> list)
-
listAsString
public static java.lang.String listAsString(java.util.List<java.lang.String> list)
-
mapAsString
public static java.lang.String mapAsString(java.util.Map<java.lang.String,java.lang.String> map) throws org.json.JSONException
- Throws:
org.json.JSONException
-
allNotBlank
public static boolean allNotBlank(java.lang.String... strings)
-
splittedStringAsList
public static java.util.List<java.lang.String> splittedStringAsList(java.lang.String string, java.lang.String delimiter)
-
jsonArrayStringAsList
public static java.util.List<java.lang.String> jsonArrayStringAsList(java.lang.String jsonString) throws org.json.JSONException
- Throws:
org.json.JSONException
-
listToJsonArray
public static org.json.JSONArray listToJsonArray(java.util.Collection<java.lang.String> list)
-
jsonObjectArrayStringAsMap
public static java.util.Map<java.lang.String,java.lang.String> jsonObjectArrayStringAsMap(java.lang.String jsonString) throws org.json.JSONException
- Parameters:
jsonString
- [{"CustomHeader1":"custom_header_value_1"},.....,{"CustomHeaderN":"custom_header_value_N"}]- Returns:
- Throws:
org.json.JSONException
-
firstItem
public static <T> T firstItem(java.util.List<T> items)
-
isNullOrEmpty
public static boolean isNullOrEmpty(java.lang.String string)
-
parseIntSilently
public static int parseIntSilently(java.lang.String intString)
-
toSHA1HexString
public static java.lang.String toSHA1HexString(java.lang.String input)
-
byteArrayToHexString
public static java.lang.String byteArrayToHexString(byte[] b)
-
getNumberOfSecondFromNow
public static java.lang.Integer getNumberOfSecondFromNow(java.util.Date date)
-
createExpirationDate
public static java.util.Date createExpirationDate(java.lang.Integer lifetimeInSeconds)
-
isPar
public static boolean isPar(java.lang.String requestUri)
-
toSerializableMap
public static java.util.Map<java.lang.String,java.io.Serializable> toSerializableMap(java.util.Map<java.lang.String,java.lang.Object> map)
-
-