76 lines
2.0 KiB
Java
76 lines
2.0 KiB
Java
package com.bumptech.glide.load;
|
|
|
|
import com.bumptech.glide.util.Preconditions;
|
|
import java.security.MessageDigest;
|
|
|
|
/* loaded from: classes.dex */
|
|
public final class Option<T> {
|
|
private static final CacheKeyUpdater<Object> e = new CacheKeyUpdater<Object>() { // from class: com.bumptech.glide.load.Option.1
|
|
@Override // com.bumptech.glide.load.Option.CacheKeyUpdater
|
|
public void a(byte[] bArr, Object obj, MessageDigest messageDigest) {
|
|
}
|
|
};
|
|
private final T a;
|
|
private final CacheKeyUpdater<T> b;
|
|
private final String c;
|
|
private volatile byte[] d;
|
|
|
|
public interface CacheKeyUpdater<T> {
|
|
void a(byte[] bArr, T t, MessageDigest messageDigest);
|
|
}
|
|
|
|
private Option(String str, T t, CacheKeyUpdater<T> cacheKeyUpdater) {
|
|
Preconditions.a(str);
|
|
this.c = str;
|
|
this.a = t;
|
|
Preconditions.a(cacheKeyUpdater);
|
|
this.b = cacheKeyUpdater;
|
|
}
|
|
|
|
public static <T> Option<T> a(String str) {
|
|
return new Option<>(str, null, b());
|
|
}
|
|
|
|
private static <T> CacheKeyUpdater<T> b() {
|
|
return (CacheKeyUpdater<T>) e;
|
|
}
|
|
|
|
private byte[] c() {
|
|
if (this.d == null) {
|
|
this.d = this.c.getBytes(Key.a);
|
|
}
|
|
return this.d;
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (obj instanceof Option) {
|
|
return this.c.equals(((Option) obj).c);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public int hashCode() {
|
|
return this.c.hashCode();
|
|
}
|
|
|
|
public String toString() {
|
|
return "Option{key='" + this.c + "'}";
|
|
}
|
|
|
|
public static <T> Option<T> a(String str, T t) {
|
|
return new Option<>(str, t, b());
|
|
}
|
|
|
|
public static <T> Option<T> a(String str, T t, CacheKeyUpdater<T> cacheKeyUpdater) {
|
|
return new Option<>(str, t, cacheKeyUpdater);
|
|
}
|
|
|
|
public T a() {
|
|
return this.a;
|
|
}
|
|
|
|
public void a(T t, MessageDigest messageDigest) {
|
|
this.b.a(c(), t, messageDigest);
|
|
}
|
|
}
|