-
@RestrictTo(value = RestrictTo.Scope.LIBRARY) public final class CTVariableUtils
-
-
Method Summary
Modifier and Type Method Description static voidupdateValuesAndKinds(String name, Array<String> nameComponents, Object value, String kind, Map<String, Object> values, Map<String, String> kinds)static Map<String, Object>convertFlatMapToNestedMaps(Map<String, Object> map)Converts a map like following: [ "android.samsung.s22" : 54000, "android.samsung.s23" : "unreleased", "welcomeMsg": "hello" ]to:[ "android": { "samsung: {"s22": 54000, "s23" : "unreleased"} }, "welcomeMsg" : "hello" ]to support legacy parsing implementationstatic ObjectmergeHelper(Object vars, Object diff)Returns the merge of vars and diff, where values in vars are replaced from valuesin diff, i.e. static Objecttraverse(Object collection, Object key, boolean autoInsert)static <T> StringkindFromValue(T defaultValue)Resolves the server type of variable by checking the generic type T of the default value. static Array<String>getNameComponents(String name)converts a string of this format : "a.b.c" to an array of strings, i. static JSONObjectgetFlatVarsJson(Map<String, Object> values, Map<String, String> kinds)static Map<Object, Object>deepCopyMap(Map<Object, Object> originalMap)-
-
Method Detail
-
updateValuesAndKinds
static void updateValuesAndKinds(String name, Array<String> nameComponents, Object value, String kind, Map<String, Object> values, Map<String, String> kinds)
-
convertFlatMapToNestedMaps
static Map<String, Object> convertFlatMapToNestedMaps(Map<String, Object> map)
Converts a map like following:
[ "android.samsung.s22" : 54000, "android.samsung.s23" : "unreleased", "welcomeMsg": "hello" ]to:[ "android": { "samsung: {"s22": 54000, "s23" : "unreleased"} }, "welcomeMsg" : "hello" ]to support legacy parsing implementation
-
mergeHelper
static Object mergeHelper(Object vars, Object diff)
Returns the merge of vars and diff, where values in vars are replaced from valuesin diff, i.e. calling mergeHelper with vars=[a:10, b:20] and diff=[a:15, c:25] produces amerge=[a:15, b:20, c:25]. The methods works recursively when nested maps are presented.
- Parameters:
vars- - Variable values as defined by user.diff- - Variable values from server.
-
kindFromValue
static <T> String kindFromValue(T defaultValue)
Resolves the server type of variable by checking the generic type T of the default value.
-
getNameComponents
static Array<String> getNameComponents(String name)
converts a string of this format : "a.b.c" to an array of strings, i.e ["a","b","c"]
-
getFlatVarsJson
static JSONObject getFlatVarsJson(Map<String, Object> values, Map<String, String> kinds)
-
-
-
-