package dev.isxander.yacl3.config.v2.api.serializer; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import dev.isxander.yacl3.config.ConfigEntry; import dev.isxander.yacl3.config.v2.api.ConfigClassHandler; import dev.isxander.yacl3.config.v2.api.ConfigSerializer; import dev.isxander.yacl3.config.v2.api.SerialEntry; import dev.isxander.yacl3.config.v2.impl.serializer.GsonConfigSerializer; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Style; import java.awt.*; import java.nio.file.Path; import java.util.function.UnaryOperator; /** * Uses GSON to serialize and deserialize config data from JSON to a file. *
* Only fields annotated with {@link dev.isxander.yacl3.config.v2.api.SerialEntry} are included in the JSON. * {@link Component}, {@link Style} and {@link Color} have default type adapters, so there is no need to provide them in your GSON instance. * GSON is automatically configured to format fields as {@code lower_camel_case}. *
* Optionally, this can also be written under JSON5 spec, allowing comments.
*
* @param
* By default, YACL sets the GSON with the following options:
*
*
* Still respects the exclusion strategy to only serialize {@link ConfigEntry}
* but these can be added to with setExclusionStrategies.
*
* @param gsonBuilder gson builder to use
*/
GsonConfigSerializerBuilder
*
* but these can be added to with setExclusionStrategies.
*
* @param gson gson instance to be converted to a builder
*/
GsonConfigSerializerBuilder
*
* For example, if you wanted to revert YACL's lower_camel_case naming policy,
* you could do the following:
*
* {@code
* GsonConfigSerializerBuilder.create(config)
* .appendGsonBuilder(builder -> builder.setFieldNamingPolicy(FieldNamingPolicy.IDENTITY))
* }
*
*
* @param gsonBuilder the function to apply to the builder
*/
GsonConfigSerializerBuilder