2022-03-07 09:34:54 +00:00
|
|
|
package lombok.core;
|
|
|
|
|
|
|
|
import com.discord.models.domain.ModelAuditLogEntry;
|
|
|
|
import com.google.android.material.shadow.ShadowDrawableWrapper;
|
|
|
|
import java.lang.ref.WeakReference;
|
|
|
|
import java.lang.reflect.Field;
|
|
|
|
import java.lang.reflect.Modifier;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.WeakHashMap;
|
|
|
|
import lombok.permit.Permit;
|
2022-03-23 22:37:04 +00:00
|
|
|
/* loaded from: com.discord-120110.apk:lombok/core/FieldAugment.SCL.lombok */
|
2022-03-07 09:34:54 +00:00
|
|
|
public abstract class FieldAugment<T, F> {
|
|
|
|
|
2022-03-23 22:37:04 +00:00
|
|
|
/* loaded from: com.discord-120110.apk:lombok/core/FieldAugment$MapFieldAugment.SCL.lombok */
|
2022-03-07 09:34:54 +00:00
|
|
|
private static class MapFieldAugment<T, F> extends FieldAugment<T, F> {
|
|
|
|
final Map<T, Object> values = new WeakHashMap();
|
|
|
|
final F defaultValue;
|
|
|
|
|
|
|
|
MapFieldAugment(F f) {
|
|
|
|
super(null);
|
|
|
|
this.defaultValue = f;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
|
|
@Override // lombok.core.FieldAugment
|
|
|
|
public F get(T t) {
|
|
|
|
FieldAugment.access$1(t, "object");
|
|
|
|
F f = this.values;
|
|
|
|
synchronized (f) {
|
|
|
|
f = read(t);
|
|
|
|
}
|
|
|
|
return f;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
|
|
@Override // lombok.core.FieldAugment
|
|
|
|
public F getAndSet(T t, F f) {
|
|
|
|
FieldAugment.access$1(t, "object");
|
|
|
|
FieldAugment.access$1(f, "value");
|
|
|
|
F f2 = this.values;
|
|
|
|
synchronized (f2) {
|
|
|
|
f2 = read(t);
|
|
|
|
write(t, f);
|
|
|
|
}
|
|
|
|
return f2;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
|
|
@Override // lombok.core.FieldAugment
|
|
|
|
public F clear(T t) {
|
|
|
|
FieldAugment.access$1(t, "object");
|
|
|
|
F f = this.values;
|
|
|
|
synchronized (f) {
|
|
|
|
f = read(t);
|
|
|
|
this.values.remove(t);
|
|
|
|
}
|
|
|
|
return f;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // lombok.core.FieldAugment
|
|
|
|
public F compareAndClear(T t, F f) {
|
|
|
|
FieldAugment.access$1(t, "object");
|
|
|
|
FieldAugment.access$1(f, "expected");
|
|
|
|
synchronized (this.values) {
|
|
|
|
F read = read(t);
|
|
|
|
if (read == null) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
if (!f.equals(read)) {
|
|
|
|
return read;
|
|
|
|
}
|
|
|
|
this.values.remove(t);
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // lombok.core.FieldAugment
|
|
|
|
public F setIfAbsent(T t, F f) {
|
|
|
|
FieldAugment.access$1(t, "object");
|
|
|
|
FieldAugment.access$1(f, "value");
|
|
|
|
synchronized (this.values) {
|
|
|
|
F read = read(t);
|
|
|
|
if (read != null) {
|
|
|
|
return read;
|
|
|
|
}
|
|
|
|
write(t, f);
|
|
|
|
return f;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // lombok.core.FieldAugment
|
|
|
|
public F compareAndSet(T t, F f, F f2) {
|
|
|
|
FieldAugment.access$1(t, "object");
|
|
|
|
FieldAugment.access$1(f, "expected");
|
|
|
|
FieldAugment.access$1(f2, "value");
|
|
|
|
synchronized (this.values) {
|
|
|
|
F read = read(t);
|
|
|
|
if (!f.equals(read)) {
|
|
|
|
return read;
|
|
|
|
}
|
|
|
|
write(t, f2);
|
|
|
|
return f2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
F read(T t) {
|
|
|
|
F f = (F) this.values.get(t);
|
|
|
|
return f == null ? this.defaultValue : f;
|
|
|
|
}
|
|
|
|
|
|
|
|
void write(T t, F f) {
|
|
|
|
this.values.put(t, f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-23 22:37:04 +00:00
|
|
|
/* loaded from: com.discord-120110.apk:lombok/core/FieldAugment$MapWeakFieldAugment.SCL.lombok */
|
2022-03-07 09:34:54 +00:00
|
|
|
static class MapWeakFieldAugment<T, F> extends MapFieldAugment<T, F> {
|
|
|
|
MapWeakFieldAugment(F f) {
|
|
|
|
super(f);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // lombok.core.FieldAugment.MapFieldAugment
|
|
|
|
F read(T t) {
|
|
|
|
WeakReference weakReference = (WeakReference) this.values.get(t);
|
|
|
|
if (weakReference == null) {
|
|
|
|
return this.defaultValue;
|
|
|
|
}
|
|
|
|
F f = (F) weakReference.get();
|
|
|
|
if (f == null) {
|
|
|
|
this.values.remove(t);
|
|
|
|
}
|
|
|
|
return f == null ? this.defaultValue : f;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // lombok.core.FieldAugment.MapFieldAugment
|
|
|
|
void write(T t, F f) {
|
|
|
|
this.values.put(t, new WeakReference(f));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-23 22:37:04 +00:00
|
|
|
/* loaded from: com.discord-120110.apk:lombok/core/FieldAugment$ReflectionFieldAugment.SCL.lombok */
|
2022-03-07 09:34:54 +00:00
|
|
|
private static class ReflectionFieldAugment<T, F> extends FieldAugment<T, F> {
|
|
|
|
private final Object lock = new Object();
|
|
|
|
private final Field field;
|
|
|
|
private final Class<F> targetType;
|
|
|
|
private final F defaultValue;
|
|
|
|
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
|
|
ReflectionFieldAugment(Field field, Class<? super F> cls, F f) {
|
|
|
|
super(null);
|
|
|
|
this.field = field;
|
|
|
|
this.targetType = cls;
|
|
|
|
this.defaultValue = f;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
|
|
/* JADX WARN: Unknown variable types count: 1 */
|
|
|
|
@Override // lombok.core.FieldAugment
|
|
|
|
/*
|
|
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
|
|
*/
|
|
|
|
public F get(T t) {
|
|
|
|
FieldAugment.access$1(t, "object");
|
|
|
|
try {
|
|
|
|
?? r0 = this.lock;
|
|
|
|
synchronized (r0) {
|
|
|
|
F cast = this.targetType.cast(this.field.get(t));
|
|
|
|
r0 = r0;
|
|
|
|
return cast == null ? this.defaultValue : cast;
|
|
|
|
}
|
|
|
|
} catch (IllegalAccessException e) {
|
|
|
|
throw new IllegalStateException(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
|
|
/* JADX WARN: Unknown variable types count: 1 */
|
|
|
|
@Override // lombok.core.FieldAugment
|
|
|
|
/*
|
|
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
|
|
*/
|
|
|
|
public F getAndSet(T t, F f) {
|
|
|
|
FieldAugment.access$1(t, "object");
|
|
|
|
FieldAugment.access$1(f, "value");
|
|
|
|
try {
|
|
|
|
?? r0 = this.lock;
|
|
|
|
synchronized (r0) {
|
|
|
|
F cast = this.targetType.cast(this.field.get(t));
|
|
|
|
this.field.set(t, f);
|
|
|
|
r0 = r0;
|
|
|
|
return cast == null ? this.defaultValue : cast;
|
|
|
|
}
|
|
|
|
} catch (IllegalAccessException e) {
|
|
|
|
throw new IllegalStateException(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
|
|
/* JADX WARN: Unknown variable types count: 1 */
|
|
|
|
@Override // lombok.core.FieldAugment
|
|
|
|
/*
|
|
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
|
|
*/
|
|
|
|
public F clear(T t) {
|
|
|
|
FieldAugment.access$1(t, "object");
|
|
|
|
try {
|
|
|
|
?? r0 = this.lock;
|
|
|
|
synchronized (r0) {
|
|
|
|
F cast = this.targetType.cast(this.field.get(t));
|
|
|
|
this.field.set(t, this.defaultValue);
|
|
|
|
r0 = r0;
|
|
|
|
return cast == null ? this.defaultValue : cast;
|
|
|
|
}
|
|
|
|
} catch (IllegalAccessException e) {
|
|
|
|
throw new IllegalStateException(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* JADX WARN: Unknown variable types count: 1 */
|
|
|
|
@Override // lombok.core.FieldAugment
|
|
|
|
/*
|
|
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
|
|
*/
|
|
|
|
public F compareAndClear(T t, F f) {
|
|
|
|
FieldAugment.access$1(t, "object");
|
|
|
|
FieldAugment.access$1(f, "expected");
|
|
|
|
try {
|
|
|
|
synchronized (this.lock) {
|
|
|
|
F cast = this.targetType.cast(this.field.get(t));
|
|
|
|
if (!f.equals(cast)) {
|
|
|
|
return cast;
|
|
|
|
}
|
|
|
|
this.field.set(t, this.defaultValue);
|
|
|
|
return this.defaultValue;
|
|
|
|
}
|
|
|
|
} catch (IllegalAccessException e) {
|
|
|
|
throw new IllegalStateException(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* JADX WARN: Unknown variable types count: 1 */
|
|
|
|
@Override // lombok.core.FieldAugment
|
|
|
|
/*
|
|
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
|
|
*/
|
|
|
|
public F setIfAbsent(T t, F f) {
|
|
|
|
FieldAugment.access$1(t, "object");
|
|
|
|
FieldAugment.access$1(f, "value");
|
|
|
|
try {
|
|
|
|
synchronized (this.lock) {
|
|
|
|
F cast = this.targetType.cast(this.field.get(t));
|
|
|
|
if (cast != null && !cast.equals(this.defaultValue)) {
|
|
|
|
return cast;
|
|
|
|
}
|
|
|
|
this.field.set(t, f);
|
|
|
|
return f;
|
|
|
|
}
|
|
|
|
} catch (IllegalAccessException e) {
|
|
|
|
throw new IllegalStateException(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* JADX WARN: Unknown variable types count: 1 */
|
|
|
|
@Override // lombok.core.FieldAugment
|
|
|
|
/*
|
|
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
|
|
*/
|
|
|
|
public F compareAndSet(T t, F f, F f2) {
|
|
|
|
FieldAugment.access$1(t, "object");
|
|
|
|
FieldAugment.access$1(f, "expected");
|
|
|
|
FieldAugment.access$1(f2, "value");
|
|
|
|
try {
|
|
|
|
synchronized (this.lock) {
|
|
|
|
F cast = this.targetType.cast(this.field.get(t));
|
|
|
|
if (!f.equals(cast)) {
|
|
|
|
return cast == null ? this.defaultValue : cast;
|
|
|
|
}
|
|
|
|
this.field.set(t, f2);
|
|
|
|
return f2;
|
|
|
|
}
|
|
|
|
} catch (IllegalAccessException e) {
|
|
|
|
throw new IllegalStateException(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private static Object getDefaultValue(Class<?> cls) {
|
|
|
|
if (cls == Boolean.TYPE) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (cls == Integer.TYPE) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if (!cls.isPrimitive()) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
if (cls == Long.TYPE) {
|
|
|
|
return 0L;
|
|
|
|
}
|
|
|
|
if (cls == Short.TYPE) {
|
|
|
|
return (short) 0;
|
|
|
|
}
|
|
|
|
if (cls == Byte.TYPE) {
|
|
|
|
return (byte) 0;
|
|
|
|
}
|
|
|
|
if (cls == Character.TYPE) {
|
|
|
|
return (char) 0;
|
|
|
|
}
|
|
|
|
if (cls == Float.TYPE) {
|
|
|
|
return Float.valueOf(0.0f);
|
|
|
|
}
|
|
|
|
if (cls == Double.TYPE) {
|
|
|
|
return Double.valueOf((double) ShadowDrawableWrapper.COS_45);
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static <T, F> FieldAugment<T, F> augment(Class<T> cls, Class<? super F> cls2, String str) {
|
|
|
|
checkNotNull(cls, "type");
|
|
|
|
checkNotNull(cls2, "fieldType");
|
|
|
|
checkNotNull(str, ModelAuditLogEntry.CHANGE_KEY_NAME);
|
|
|
|
Object defaultValue = getDefaultValue(cls2);
|
|
|
|
FieldAugment<T, F> tryCreateReflectionAugment = tryCreateReflectionAugment(cls, cls2, str, defaultValue);
|
|
|
|
return tryCreateReflectionAugment != null ? tryCreateReflectionAugment : new MapFieldAugment(defaultValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static <T, F> FieldAugment<T, F> circularSafeAugment(Class<T> cls, Class<? super F> cls2, String str) {
|
|
|
|
checkNotNull(cls, "type");
|
|
|
|
checkNotNull(cls2, "fieldType");
|
|
|
|
checkNotNull(str, ModelAuditLogEntry.CHANGE_KEY_NAME);
|
|
|
|
Object defaultValue = getDefaultValue(cls2);
|
|
|
|
FieldAugment<T, F> tryCreateReflectionAugment = tryCreateReflectionAugment(cls, cls2, str, defaultValue);
|
|
|
|
return tryCreateReflectionAugment != null ? tryCreateReflectionAugment : new MapWeakFieldAugment(defaultValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
private static <T, F> FieldAugment<T, F> tryCreateReflectionAugment(Class<T> cls, Class<? super F> cls2, String str, F f) {
|
|
|
|
Field findField = findField(cls, cls2, str);
|
|
|
|
if (findField == null || !typeIsAssignmentCompatible(findField.getType(), cls2)) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
return new ReflectionFieldAugment(findField, cls2, f);
|
|
|
|
}
|
|
|
|
|
|
|
|
private static Field findField(Class<?> cls, Class<?> cls2, String str) {
|
|
|
|
try {
|
|
|
|
Field field = Permit.getField(cls, str);
|
|
|
|
if (Modifier.isStatic(field.getModifiers()) || Modifier.isFinal(field.getModifiers())) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
if (!typeIsAssignmentCompatible(field.getType(), cls2)) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
return field;
|
|
|
|
} catch (Exception unused) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private static boolean typeIsAssignmentCompatible(Class<?> cls, Class<?> cls2) {
|
|
|
|
if (cls == Object.class || cls == cls2) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (cls.isPrimitive()) {
|
|
|
|
return cls == cls2;
|
|
|
|
}
|
|
|
|
if (cls2 == Integer.TYPE && (cls == Number.class || cls == Integer.class)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (cls2 == Long.TYPE && (cls == Number.class || cls == Long.class)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (cls2 == Short.TYPE && (cls == Number.class || cls == Short.class)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (cls2 == Byte.TYPE && (cls == Number.class || cls == Byte.class)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (cls2 == Character.TYPE && (cls == Number.class || cls == Character.class)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (cls2 == Float.TYPE && (cls == Number.class || cls == Float.class)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (cls2 == Double.TYPE && (cls == Number.class || cls == Double.class)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (cls2 == Boolean.TYPE && cls == Boolean.class) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return cls.isAssignableFrom(cls2);
|
|
|
|
}
|
|
|
|
|
|
|
|
private FieldAugment() {
|
|
|
|
}
|
|
|
|
|
|
|
|
public abstract F get(T t);
|
|
|
|
|
|
|
|
public final void set(T t, F f) {
|
|
|
|
getAndSet(t, f);
|
|
|
|
}
|
|
|
|
|
|
|
|
public abstract F getAndSet(T t, F f);
|
|
|
|
|
|
|
|
public abstract F clear(T t);
|
|
|
|
|
|
|
|
public abstract F compareAndClear(T t, F f);
|
|
|
|
|
|
|
|
public abstract F setIfAbsent(T t, F f);
|
|
|
|
|
|
|
|
public abstract F compareAndSet(T t, F f, F f2);
|
|
|
|
|
|
|
|
private static <T> T checkNotNull(T t, String str) {
|
|
|
|
if (t != null) {
|
|
|
|
return t;
|
|
|
|
}
|
|
|
|
throw new NullPointerException(str);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* synthetic */ FieldAugment(FieldAugment fieldAugment) {
|
|
|
|
this();
|
|
|
|
}
|
|
|
|
|
|
|
|
static /* synthetic */ Object access$1(Object obj, String str) {
|
|
|
|
return checkNotNull(obj, str);
|
|
|
|
}
|
|
|
|
}
|