package androidx.work;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import java.util.HashMap;
import java.util.Map;

/* JADX INFO: loaded from: classes.dex */
public final class h {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final HashMap f4560a = new HashMap();

    public final i a() {
        i iVar = new i(this.f4560a);
        i.b(iVar);
        return iVar;
    }

    public final void b(HashMap map) {
        for (Map.Entry entry : map.entrySet()) {
            put((String) entry.getKey(), entry.getValue());
        }
    }

    @NonNull
    @RestrictTo({RestrictTo.Scope.f556b})
    public h put(@NonNull String str, @Nullable Object obj) {
        HashMap map = this.f4560a;
        if (obj == null) {
            map.put(str, null);
        } else {
            Class<?> cls = obj.getClass();
            if (cls == Boolean.class || cls == Byte.class || cls == Integer.class || cls == Long.class || cls == Float.class || cls == Double.class || cls == String.class || cls == Boolean[].class || cls == Byte[].class || cls == Integer[].class || cls == Long[].class || cls == Float[].class || cls == Double[].class || cls == String[].class) {
                map.put(str, obj);
            } else {
                int i10 = 0;
                if (cls == boolean[].class) {
                    boolean[] zArr = (boolean[]) obj;
                    i iVar = i.f4564b;
                    Boolean[] boolArr = new Boolean[zArr.length];
                    while (i10 < zArr.length) {
                        boolArr[i10] = Boolean.valueOf(zArr[i10]);
                        i10++;
                    }
                    map.put(str, boolArr);
                } else if (cls == byte[].class) {
                    byte[] bArr = (byte[]) obj;
                    i iVar2 = i.f4564b;
                    Byte[] bArr2 = new Byte[bArr.length];
                    while (i10 < bArr.length) {
                        bArr2[i10] = Byte.valueOf(bArr[i10]);
                        i10++;
                    }
                    map.put(str, bArr2);
                } else if (cls == int[].class) {
                    int[] iArr = (int[]) obj;
                    i iVar3 = i.f4564b;
                    Integer[] numArr = new Integer[iArr.length];
                    while (i10 < iArr.length) {
                        numArr[i10] = Integer.valueOf(iArr[i10]);
                        i10++;
                    }
                    map.put(str, numArr);
                } else if (cls == long[].class) {
                    long[] jArr = (long[]) obj;
                    i iVar4 = i.f4564b;
                    Long[] lArr = new Long[jArr.length];
                    while (i10 < jArr.length) {
                        lArr[i10] = Long.valueOf(jArr[i10]);
                        i10++;
                    }
                    map.put(str, lArr);
                } else if (cls == float[].class) {
                    float[] fArr = (float[]) obj;
                    i iVar5 = i.f4564b;
                    Float[] fArr2 = new Float[fArr.length];
                    while (i10 < fArr.length) {
                        fArr2[i10] = Float.valueOf(fArr[i10]);
                        i10++;
                    }
                    map.put(str, fArr2);
                } else {
                    if (cls != double[].class) {
                        throw new IllegalArgumentException(String.format("Key %s has invalid type %s", str, cls));
                    }
                    double[] dArr = (double[]) obj;
                    i iVar6 = i.f4564b;
                    Double[] dArr2 = new Double[dArr.length];
                    while (i10 < dArr.length) {
                        dArr2[i10] = Double.valueOf(dArr[i10]);
                        i10++;
                    }
                    map.put(str, dArr2);
                }
            }
        }
        return this;
    }

    @NonNull
    public h putString(@NonNull String str, @Nullable String str2) {
        this.f4560a.put(str, str2);
        return this;
    }
}
