package com.bytedance.bpea.basics;

import X.9qj;
import X.GJD;
import X.IHI;
import X.IOD;
import X.M12;
import X.RYC;
import com.bytedance.covode.number.Covode;
import java.util.Arrays;
import kotlin.h.b.n;
import kotlin.o.y;
import org.json.JSONArray;
import org.json.JSONObject;

public final class PrivacyCert extends IOD {
    public final GJD privacyPoint;
    public final 9qj[] privacyPolicies;
    public final String usage;

    static {
        Covode.recordClassIndex(24513);
    }

    public static /* synthetic */ PrivacyCert copy$default(PrivacyCert privacyCert, GJD gjd, String str, 9qj[] r4, int i, Object obj) {
        if ((i & 1) != 0) {
            gjd = privacyCert.privacyPoint;
        }
        if ((i & 2) != 0) {
            str = privacyCert.usage;
        }
        if ((i & 4) != 0) {
            r4 = privacyCert.privacyPolicies;
        }
        return privacyCert.copy(gjd, str, r4);
    }

    public final PrivacyCert copy(GJD gjd, String str, 9qj[] r4) {
        return new PrivacyCert(gjd, str, r4);
    }

    public final boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (!(obj instanceof PrivacyCert)) {
            return false;
        }
        PrivacyCert privacyCert = (PrivacyCert) obj;
        return n.LIZ(this.privacyPoint, privacyCert.privacyPoint) && n.LIZ(this.usage, privacyCert.usage) && n.LIZ(this.privacyPolicies, privacyCert.privacyPolicies);
    }

    public final int hashCode() {
        GJD gjd = this.privacyPoint;
        int i = 0;
        int hashCode = (gjd != null ? gjd.hashCode() : 0) * 31;
        String str = this.usage;
        int hashCode2 = (hashCode + (str != null ? str.hashCode() : 0)) * 31;
        9qj[] r0 = this.privacyPolicies;
        if (r0 != null) {
            i = Arrays.hashCode(r0);
        }
        return hashCode2 + i;
    }

    public final String toString() {
        return "PrivacyCert(privacyPoint=" + this.privacyPoint + ", usage=" + this.usage + ", privacyPolicies=" + Arrays.toString(this.privacyPolicies) + ")";
    }

    public final GJD getPrivacyPoint() {
        return this.privacyPoint;
    }

    public final 9qj[] getPrivacyPolicies() {
        return this.privacyPolicies;
    }

    public final String getUsage() {
        return this.usage;
    }

    public final JSONObject toJSON() {
        String str;
        JSONObject json = super.toJSON();
        try {
            json.put("usage", this.usage);
            GJD gjd = this.privacyPoint;
            if (gjd != null) {
                str = gjd.getTag();
            } else {
                str = null;
            }
            json.put("tag", str);
            JSONArray jSONArray = new JSONArray();
            9qj[] r3 = this.privacyPolicies;
            if (r3 != null) {
                for (9qj dataType : r3) {
                    jSONArray.put(dataType.getDataType());
                }
            }
            json.put("dataType", jSONArray.toString());
        } catch (Throwable unused) {
        }
        return json;
    }

    public final void validate(RYC ryc) {
        String id;
        M12.LIZ(ryc);
        super.validate(ryc);
        GJD gjd = this.privacyPoint;
        if (gjd == null || (id = gjd.getId()) == null || y.LIZ(id)) {
            throw new IHI(-1, "certId is empty");
        }
        9qj[] r0 = this.privacyPolicies;
        if (r0 == null || r0.length == 0) {
            throw new IHI(-1, "policy is empty");
        }
        String[] strArr = ryc.LIZLLL;
        if (strArr == null || strArr.length == 0) {
            throw new IHI(-1, "check dataType is empty");
        }
        String[] strArr2 = ryc.LIZLLL;
        if (strArr2 != null) {
            int length = strArr2.length;
            int i = 0;
            while (i < length) {
                String str = strArr2[i];
                boolean z = false;
                for (9qj dataType : this.privacyPolicies) {
                    String dataType2 = dataType.getDataType();
                    if (dataType2 != null && dataType2.equals(str)) {
                        z = true;
                    }
                }
                if (z) {
                    i++;
                } else {
                    throw new IHI(-1, "dataType do not match");
                }
            }
        }
    }

    /* JADX WARNING: Illegal instructions before constructor call */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public PrivacyCert(X.GJD r3, java.lang.String r4, X.9qj[] r5) {
        /*
            r2 = this;
            if (r3 == 0) goto L_0x0016
            java.lang.String r1 = r3.getId()
        L_0x0006:
            X.IOE r0 = X.IOE.PRIVACY_CERT
            int r0 = r0.getType()
            r2.<init>(r1, r0)
            r2.privacyPoint = r3
            r2.usage = r4
            r2.privacyPolicies = r5
            return
        L_0x0016:
            r1 = 0
            goto L_0x0006
        */
        throw new UnsupportedOperationException("Method not decompiled: com.bytedance.bpea.basics.PrivacyCert.<init>(X.GJD, java.lang.String, X.9qj[]):void");
    }
}
