jimu-decompiled/sources/com/baidu/uaq/agent/android/metric/a.java
2025-05-13 19:24:51 +02:00

116 lines
3.0 KiB
Java

package com.baidu.uaq.agent.android.metric;
import com.baidu.uaq.agent.android.harvest.type.d;
import com.baidu.uaq.agent.android.logging.b;
import com.liulishuo.filedownloader.model.FileDownloadModel;
import org.json.JSONException;
import org.json.JSONObject;
/* compiled from: Metric.java */
/* loaded from: classes.dex */
public class a extends d {
private static final com.baidu.uaq.agent.android.logging.a j = b.a();
private String b;
private String c;
private Double d;
private Double e;
private Double f;
private Double g;
private Double h;
private long i;
public a(String str) {
this(str, null);
}
private void b(Double d) {
if (d == null) {
return;
}
if (this.e == null) {
this.e = d;
} else if (d.doubleValue() > this.e.doubleValue()) {
this.e = d;
}
}
public void a(double d) {
this.i++;
Double d2 = this.f;
if (d2 == null) {
this.f = Double.valueOf(d);
this.g = Double.valueOf(d * d);
} else {
this.f = Double.valueOf(d2.doubleValue() + d);
this.g = Double.valueOf(this.g.doubleValue() + (d * d));
}
a(Double.valueOf(d));
b(Double.valueOf(d));
}
@Override // com.baidu.uaq.agent.android.harvest.type.a
public JSONObject d() {
JSONObject jSONObject = new JSONObject();
try {
jSONObject.put("count", this.i);
if (this.f != null) {
jSONObject.put(FileDownloadModel.TOTAL, this.f);
}
if (this.d != null) {
jSONObject.put("min", this.d);
}
if (this.e != null) {
jSONObject.put("max", this.e);
}
if (this.g != null) {
jSONObject.put("sum_of_squares", this.g);
}
if (this.h != null) {
jSONObject.put("exclusive", this.h);
}
} catch (JSONException e) {
j.a("Caught error while Metric asJSONObject: ", e);
com.baidu.uaq.agent.android.harvest.health.a.a(e);
}
return jSONObject;
}
public String e() {
String str = this.c;
return str != null ? str : "";
}
public String f() {
return this.b;
}
public void g() {
a(1L);
}
public String toString() {
return "Metric{name='" + this.b + "', scope='" + this.c + "', min=" + this.d + ", max=" + this.e + ", total=" + this.f + ", sumOfSquares=" + this.g + ", exclusive=" + this.h + ", count=" + this.i + '}';
}
public a(String str, String str2) {
this.b = str;
this.c = str2;
this.i = 0L;
}
private void a(Double d) {
if (d == null) {
return;
}
if (this.d == null) {
this.d = d;
} else if (d.doubleValue() < this.d.doubleValue()) {
this.d = d;
}
}
public void a(long j2) {
this.i += j2;
}
}