what-the-bank/sources/okhttp3/repackaged/CacheControl.java

230 lines
6.7 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package okhttp3.repackaged;
import java.util.concurrent.TimeUnit;
/* loaded from: classes6.dex */
public final class CacheControl {
private final int aha;
private final boolean ahb;
private final boolean ahc;
private final boolean ahd;
String headerValue;
private final int maxAgeSeconds;
private final int maxStaleSeconds;
private final int minFreshSeconds;
private final boolean noCache;
private final boolean noStore;
private final boolean noTransform;
private final boolean onlyIfCached;
public static final CacheControl FORCE_NETWORK = new Builder().noCache().build();
public static final CacheControl FORCE_CACHE = new Builder().onlyIfCached().maxStale(Integer.MAX_VALUE, TimeUnit.SECONDS).build();
private CacheControl(boolean z, boolean z2, int i, int i2, boolean z3, boolean z4, boolean z5, int i3, int i4, boolean z6, boolean z7, String str) {
this.noCache = z;
this.noStore = z2;
this.maxAgeSeconds = i;
this.aha = i2;
this.ahb = z3;
this.ahc = z4;
this.ahd = z5;
this.maxStaleSeconds = i3;
this.minFreshSeconds = i4;
this.onlyIfCached = z6;
this.noTransform = z7;
this.headerValue = str;
}
private CacheControl(Builder builder) {
this.noCache = builder.noCache;
this.noStore = builder.noStore;
this.maxAgeSeconds = builder.maxAgeSeconds;
this.aha = -1;
this.ahb = false;
this.ahc = false;
this.ahd = false;
this.maxStaleSeconds = builder.maxStaleSeconds;
this.minFreshSeconds = builder.minFreshSeconds;
this.onlyIfCached = builder.onlyIfCached;
this.noTransform = builder.noTransform;
}
/* JADX WARN: Removed duplicated region for block: B:10:0x003e */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public static okhttp3.repackaged.CacheControl parse(okhttp3.repackaged.Headers r22) {
/*
Method dump skipped, instructions count: 324
To view this dump add '--comments-level debug' option
*/
throw new UnsupportedOperationException("Method not decompiled: okhttp3.repackaged.CacheControl.parse(okhttp3.repackaged.Headers):okhttp3.repackaged.CacheControl");
}
public final String toString() {
String str = this.headerValue;
if (str != null) {
return str;
}
String ul = ul();
this.headerValue = ul;
return ul;
}
private String ul() {
StringBuilder sb = new StringBuilder();
if (this.noCache) {
sb.append("no-cache, ");
}
if (this.noStore) {
sb.append("no-store, ");
}
if (this.maxAgeSeconds != -1) {
sb.append("max-age=");
sb.append(this.maxAgeSeconds);
sb.append(", ");
}
if (this.aha != -1) {
sb.append("s-maxage=");
sb.append(this.aha);
sb.append(", ");
}
if (this.ahb) {
sb.append("private, ");
}
if (this.ahc) {
sb.append("public, ");
}
if (this.ahd) {
sb.append("must-revalidate, ");
}
if (this.maxStaleSeconds != -1) {
sb.append("max-stale=");
sb.append(this.maxStaleSeconds);
sb.append(", ");
}
if (this.minFreshSeconds != -1) {
sb.append("min-fresh=");
sb.append(this.minFreshSeconds);
sb.append(", ");
}
if (this.onlyIfCached) {
sb.append("only-if-cached, ");
}
if (this.noTransform) {
sb.append("no-transform, ");
}
if (sb.length() == 0) {
return "";
}
sb.delete(sb.length() - 2, sb.length());
return sb.toString();
}
/* loaded from: classes6.dex */
public static final class Builder {
int maxAgeSeconds = -1;
int maxStaleSeconds = -1;
int minFreshSeconds = -1;
boolean noCache;
boolean noStore;
boolean noTransform;
boolean onlyIfCached;
public final Builder maxAge(int i, TimeUnit timeUnit) {
if (i < 0) {
throw new IllegalArgumentException("maxAge < 0: ".concat(String.valueOf(i)));
}
long seconds = timeUnit.toSeconds(i);
this.maxAgeSeconds = seconds > 2147483647L ? Integer.MAX_VALUE : (int) seconds;
return this;
}
public final Builder maxStale(int i, TimeUnit timeUnit) {
if (i < 0) {
throw new IllegalArgumentException("maxStale < 0: ".concat(String.valueOf(i)));
}
long seconds = timeUnit.toSeconds(i);
this.maxStaleSeconds = seconds > 2147483647L ? Integer.MAX_VALUE : (int) seconds;
return this;
}
public final Builder minFresh(int i, TimeUnit timeUnit) {
if (i < 0) {
throw new IllegalArgumentException("minFresh < 0: ".concat(String.valueOf(i)));
}
long seconds = timeUnit.toSeconds(i);
this.minFreshSeconds = seconds > 2147483647L ? Integer.MAX_VALUE : (int) seconds;
return this;
}
public final CacheControl build() {
return new CacheControl(this);
}
public final Builder onlyIfCached() {
this.onlyIfCached = true;
return this;
}
public final Builder noTransform() {
this.noTransform = true;
return this;
}
public final Builder noStore() {
this.noStore = true;
return this;
}
public final Builder noCache() {
this.noCache = true;
return this;
}
}
public final int sMaxAgeSeconds() {
return this.aha;
}
public final boolean onlyIfCached() {
return this.onlyIfCached;
}
public final boolean noTransform() {
return this.noTransform;
}
public final boolean noStore() {
return this.noStore;
}
public final boolean noCache() {
return this.noCache;
}
public final boolean mustRevalidate() {
return this.ahd;
}
public final int minFreshSeconds() {
return this.minFreshSeconds;
}
public final int maxStaleSeconds() {
return this.maxStaleSeconds;
}
public final int maxAgeSeconds() {
return this.maxAgeSeconds;
}
public final boolean isPublic() {
return this.ahc;
}
public final boolean isPrivate() {
return this.ahb;
}
}