what-the-bank/sources/com/huawei/hms/framework/common/hianalytics/HianalyticsBaseData.java

78 lines
2.5 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package com.huawei.hms.framework.common.hianalytics;
import com.huawei.hms.framework.common.Logger;
import java.util.LinkedHashMap;
import java.util.Map;
import org.json.JSONException;
import org.json.JSONObject;
/* loaded from: classes2.dex */
public abstract class HianalyticsBaseData {
public static final String EVENT_ID = "url_request";
public static final int FALSE = 0;
public static final String SDK_NAME = "sdk_name";
public static final String SDK_TYPE = "sdk_type";
public static final String SDK_VERSION = "sdk_version";
private static final String TAG = "HianalyticsBaseData";
public static final int TRUE = 1;
private LinkedHashMap<String, String> data;
public HianalyticsBaseData() {
LinkedHashMap<String, String> linkedHashMap = new LinkedHashMap<>();
this.data = linkedHashMap;
linkedHashMap.put(SDK_TYPE, "UxPP");
this.data.put(SDK_NAME, "networkkit");
}
public HianalyticsBaseData put(String str, String str2) {
if (str == null || str2 == null) {
StringBuilder sb = new StringBuilder("key = ");
sb.append(str);
sb.append(" : value = ");
sb.append(str2);
Logger.v(TAG, sb.toString());
} else {
this.data.put(str, str2);
}
return this;
}
public HianalyticsBaseData put(String str, long j) {
if (str == null) {
Logger.v(TAG, "key = null : value = ".concat(String.valueOf(j)));
} else {
this.data.put(str, "".concat(String.valueOf(j)));
}
return this;
}
public HianalyticsBaseData put(LinkedHashMap<String, String> linkedHashMap) {
if (linkedHashMap == null || linkedHashMap.isEmpty()) {
Logger.v(TAG, "data is null");
} else {
this.data.putAll(linkedHashMap);
}
return this;
}
public HianalyticsBaseData putIfNotDefault(String str, long j, long j2) {
return j == j2 ? this : put(str, j);
}
public String toString() {
JSONObject jSONObject = new JSONObject();
try {
for (Map.Entry<String, String> entry : get().entrySet()) {
jSONObject.put(entry.getKey(), entry.getValue());
}
} catch (JSONException e) {
Logger.w(TAG, "catch JSONException", e);
}
return jSONObject.toString();
}
public LinkedHashMap<String, String> get() {
return this.data;
}
}