你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
Tools Class
- java.
lang. Object - com.
microsoft. azure. sdk. iot. service. Tools
- com.
public class Tools
Collection of static helper functions
Constructor Summary
Constructor | Description | |
---|---|---|
Tools() |
Method Summary
Modifier and Type | Method and Description |
---|---|
static void |
appendJsonAttribute(StringBuilder strBuilder, String name, String value, Boolean isQuoted, Boolean isLast)
Helper function to properly craft Json string of key-value pair |
static boolean |
areEqual(Object a, Object b)
Equality check for objects that accounts for null value comparisons. |
static long |
getNumberValueFromJsonObject(JsonObject jsonObject, String key)
Helper function to get numeric value from a Json |
static java.lang.String |
getValueFromJsonObject(JsonObject jsonObject, String key)
Helper function to get a value from the given Json |
static java.lang.String |
getValueFromJsonString(JsonString jsonString)
Helper function to get trim the leading and trailing parenthesis from a Json string if they exists |
static java.lang.String |
getValueStringByKey(Map<String,?> map, String keyName)
Helper function to get a value from the given Map if the key name exists |
static java.lang.Boolean |
isNullOrEmpty(String value)
Helper function to check if the input string is null or empty |
static java.lang.Boolean |
isNullOrWhiteSpace(String value)
Helper function to check if the input string is null or contains only whitespace(s) |
Methods inherited from java.lang.Object
Constructor Details
Tools
public Tools()
Method Details
appendJsonAttribute
public static void appendJsonAttribute(StringBuilder strBuilder, String name, String value, Boolean isQuoted, Boolean isLast)
Helper function to properly craft Json string of key-value pair
Parameters:
areEqual
public static boolean areEqual(Object a, Object b)
Equality check for objects that accounts for null value comparisons. If both objects are null, this will return false. Both objects must have .equals(...) implemented correctly for this method to work properly.
Parameters:
Returns:
getNumberValueFromJsonObject
public static long getNumberValueFromJsonObject(JsonObject jsonObject, String key)
Helper function to get numeric value from a JsonObject
Parameters:
Returns:
getValueFromJsonObject
public static String getValueFromJsonObject(JsonObject jsonObject, String key)
Helper function to get a value from the given JsonObject if the key name exists
Parameters:
Returns:
getValueFromJsonString
public static String getValueFromJsonString(JsonString jsonString)
Helper function to get trim the leading and trailing parenthesis from a Json string if they exists
Parameters:
Returns:
getValueStringByKey
public static String getValueStringByKey(Map
Helper function to get a value from the given Map if the key name exists
Parameters:
Returns:
isNullOrEmpty
public static Boolean isNullOrEmpty(String value)
Helper function to check if the input string is null or empty
Parameters:
Returns:
isNullOrWhiteSpace
public static Boolean isNullOrWhiteSpace(String value)
Helper function to check if the input string is null or contains only whitespace(s)
Parameters:
Returns: