package h;

import java.io.InterruptedIOException;
import java.util.concurrent.TimeUnit;

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

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

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public boolean f6572b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public long f6573c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public long f6574d;

    public class a extends y {
        @Override // h.y
        public y d(long j2) {
            return this;
        }

        @Override // h.y
        public void f() {
        }

        @Override // h.y
        public y g(long j2, TimeUnit timeUnit) {
            return this;
        }
    }

    public y a() {
        this.f6572b = false;
        return this;
    }

    public y b() {
        this.f6574d = 0L;
        return this;
    }

    public long c() {
        if (this.f6572b) {
            return this.f6573c;
        }
        throw new IllegalStateException("No deadline");
    }

    public y d(long j2) {
        this.f6572b = true;
        this.f6573c = j2;
        return this;
    }

    public boolean e() {
        return this.f6572b;
    }

    public void f() throws InterruptedIOException {
        if (Thread.interrupted()) {
            Thread.currentThread().interrupt();
            throw new InterruptedIOException("interrupted");
        }
        if (this.f6572b && this.f6573c - System.nanoTime() <= 0) {
            throw new InterruptedIOException("deadline reached");
        }
    }

    public y g(long j2, TimeUnit timeUnit) {
        if (j2 >= 0) {
            if (timeUnit == null) {
                throw new IllegalArgumentException("unit == null");
            }
            this.f6574d = timeUnit.toNanos(j2);
            return this;
        }
        throw new IllegalArgumentException("timeout < 0: " + j2);
    }
}
