what-the-bank/sources/com/google/firebase/remoteconfig/internal/ConfigContainer.java

131 lines
4.3 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package com.google.firebase.remoteconfig.internal;
import java.util.Date;
import java.util.Map;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
/* loaded from: classes.dex */
public class ConfigContainer {
private static final Date DEFAULTS_FETCH_TIME = new Date(0);
private JSONArray abtExperiments;
private JSONObject configsJson;
private JSONObject containerJson;
private Date fetchTime;
private JSONObject personalizationMetadata;
private ConfigContainer(JSONObject jSONObject, Date date, JSONArray jSONArray, JSONObject jSONObject2) throws JSONException {
JSONObject jSONObject3 = new JSONObject();
jSONObject3.put("configs_key", jSONObject);
jSONObject3.put("fetch_time_key", date.getTime());
jSONObject3.put("abt_experiments_key", jSONArray);
jSONObject3.put("personalization_metadata_key", jSONObject2);
this.configsJson = jSONObject;
this.fetchTime = date;
this.abtExperiments = jSONArray;
this.personalizationMetadata = jSONObject2;
this.containerJson = jSONObject3;
}
/* JADX INFO: Access modifiers changed from: package-private */
public static ConfigContainer copyOf(JSONObject jSONObject) throws JSONException {
JSONObject optJSONObject = jSONObject.optJSONObject("personalization_metadata_key");
if (optJSONObject == null) {
optJSONObject = new JSONObject();
}
return new ConfigContainer(jSONObject.getJSONObject("configs_key"), new Date(jSONObject.getLong("fetch_time_key")), jSONObject.getJSONArray("abt_experiments_key"), optJSONObject);
}
public String toString() {
return this.containerJson.toString();
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof ConfigContainer) {
return this.containerJson.toString().equals(((ConfigContainer) obj).toString());
}
return false;
}
public int hashCode() {
return this.containerJson.hashCode();
}
/* loaded from: classes.dex */
public static class Builder {
private JSONArray builderAbtExperiments;
private JSONObject builderConfigsJson;
private Date builderFetchTime;
private JSONObject builderPersonalizationMetadata;
private Builder() {
this.builderConfigsJson = new JSONObject();
this.builderFetchTime = ConfigContainer.DEFAULTS_FETCH_TIME;
this.builderAbtExperiments = new JSONArray();
this.builderPersonalizationMetadata = new JSONObject();
}
public Builder replaceConfigsWith(Map<String, String> map) {
this.builderConfigsJson = new JSONObject(map);
return this;
}
public Builder replaceConfigsWith(JSONObject jSONObject) {
try {
this.builderConfigsJson = new JSONObject(jSONObject.toString());
} catch (JSONException unused) {
}
return this;
}
public Builder withAbtExperiments(JSONArray jSONArray) {
try {
this.builderAbtExperiments = new JSONArray(jSONArray.toString());
} catch (JSONException unused) {
}
return this;
}
public Builder withPersonalizationMetadata(JSONObject jSONObject) {
try {
this.builderPersonalizationMetadata = new JSONObject(jSONObject.toString());
} catch (JSONException unused) {
}
return this;
}
public ConfigContainer build() throws JSONException {
return new ConfigContainer(this.builderConfigsJson, this.builderFetchTime, this.builderAbtExperiments, this.builderPersonalizationMetadata);
}
public Builder withFetchTime(Date date) {
this.builderFetchTime = date;
return this;
}
}
public static Builder newBuilder() {
return new Builder();
}
public JSONObject getPersonalizationMetadata() {
return this.personalizationMetadata;
}
public Date getFetchTime() {
return this.fetchTime;
}
public JSONObject getConfigs() {
return this.configsJson;
}
public JSONArray getAbtExperiments() {
return this.abtExperiments;
}
}