/* * Decompiled with CFR 0.152. * * Could not load the following classes: * com.google.gson.ExclusionStrategy * com.google.gson.FieldAttributes * com.google.gson.Gson * com.google.gson.GsonBuilder * com.google.gson.JsonElement * org.jspecify.annotations.Nullable */ package com.mojang.realmsclient.dto; import com.google.gson.ExclusionStrategy; import com.google.gson.FieldAttributes; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonElement; import com.mojang.realmsclient.dto.Exclude; import com.mojang.realmsclient.dto.ReflectionBasedSerialization; import org.jspecify.annotations.Nullable; public class GuardedSerializer { ExclusionStrategy strategy = new ExclusionStrategy(this){ public boolean shouldSkipClass(Class clazz) { return false; } public boolean shouldSkipField(FieldAttributes field) { return field.getAnnotation(Exclude.class) != null; } }; private final Gson gson = new GsonBuilder().addSerializationExclusionStrategy(this.strategy).addDeserializationExclusionStrategy(this.strategy).create(); public String toJson(ReflectionBasedSerialization object) { return this.gson.toJson((Object)object); } public String toJson(JsonElement jsonElement) { return this.gson.toJson(jsonElement); } public @Nullable T fromJson(String contents, Class cls) { return (T)((ReflectionBasedSerialization)this.gson.fromJson(contents, cls)); } }