package i;

import java.lang.reflect.Type;
import java.text.DecimalFormat;

/* JADX INFO: renamed from: i.x, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public class C0543x implements U {

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public static final C0543x f4382b = new C0543x();

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    private DecimalFormat f4383a;

    public C0543x() {
        this.f4383a = null;
    }

    @Override // i.U
    public void a(C0516I c0516i, Object obj, Object obj2, Type type, int i2) {
        e0 e0Var = c0516i.f4223k;
        if (obj == null) {
            e0Var.N(f0.WriteNullNumberAsZero);
            return;
        }
        double dDoubleValue = ((Double) obj).doubleValue();
        if (Double.isNaN(dDoubleValue) || Double.isInfinite(dDoubleValue)) {
            e0Var.K();
            return;
        }
        DecimalFormat decimalFormat = this.f4383a;
        if (decimalFormat == null) {
            e0Var.n(dDoubleValue, true);
        } else {
            e0Var.write(decimalFormat.format(dDoubleValue));
        }
    }

    public C0543x(DecimalFormat decimalFormat) {
        this.f4383a = decimalFormat;
    }

    public C0543x(String str) {
        this(new DecimalFormat(str));
    }
}
