Class GsonProvider

java.lang.Object
dev.demeng.pluginbase.gson.GsonProvider

public final class GsonProvider extends Object
Provides static instances of Gson.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static @NotNull com.google.gson.JsonParser
    Returns the shared JsonParser instance.
    static @NotNull com.google.gson.Gson
    Returns a Gson instance configured with pretty printing, null serialization, and HTML escaping disabled.
    static @NotNull com.google.gson.JsonObject
    readObject(@NotNull Reader reader)
    Parses the content of the given Reader into a JsonObject.
    static @NotNull com.google.gson.JsonObject
    readObject(@NotNull String s)
    Parses a JSON string into a JsonObject.
    static @NotNull com.google.gson.Gson
    Returns the standard Gson instance configured with null serialization and HTML escaping disabled.
    static @NotNull String
    toString(@NotNull com.google.gson.JsonElement element)
    Serializes a JsonElement to a string using standard formatting.
    static @NotNull String
    toStringPretty(@NotNull com.google.gson.JsonElement element)
    Serializes a JsonElement to a pretty-printed string.
    static void
    writeElement(@NotNull Appendable writer, @NotNull com.google.gson.JsonElement element)
    Serializes a JsonElement to the given Appendable using standard formatting.
    static void
    writeElementPretty(@NotNull Appendable writer, @NotNull com.google.gson.JsonElement element)
    Serializes a JsonElement to the given Appendable using pretty-print formatting.
    static void
    writeObject(@NotNull Appendable writer, @NotNull com.google.gson.JsonObject object)
    Serializes a JsonObject to the given Appendable using standard formatting.
    static void
    writeObjectPretty(@NotNull Appendable writer, @NotNull com.google.gson.JsonObject object)
    Serializes a JsonObject to the given Appendable using pretty-print formatting.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • GsonProvider

      public GsonProvider()
  • Method Details

    • standard

      @NotNull public static @NotNull com.google.gson.Gson standard()
      Returns the standard Gson instance configured with null serialization and HTML escaping disabled.
      Returns:
      the standard Gson instance
    • prettyPrinting

      @NotNull public static @NotNull com.google.gson.Gson prettyPrinting()
      Returns a Gson instance configured with pretty printing, null serialization, and HTML escaping disabled.
      Returns:
      the pretty-printing Gson instance
    • parser

      @NotNull public static @NotNull com.google.gson.JsonParser parser()
      Returns the shared JsonParser instance.
      Returns:
      the shared JsonParser
    • readObject

      @NotNull public static @NotNull com.google.gson.JsonObject readObject(@NotNull @NotNull Reader reader)
      Parses the content of the given Reader into a JsonObject.
      Parameters:
      reader - the reader supplying the JSON content
      Returns:
      the parsed JsonObject
    • readObject

      @NotNull public static @NotNull com.google.gson.JsonObject readObject(@NotNull @NotNull String s)
      Parses a JSON string into a JsonObject.
      Parameters:
      s - the JSON string to parse
      Returns:
      the parsed JsonObject
    • writeObject

      public static void writeObject(@NotNull @NotNull Appendable writer, @NotNull @NotNull com.google.gson.JsonObject object)
      Serializes a JsonObject to the given Appendable using standard formatting.
      Parameters:
      writer - the target to write the JSON to
      object - the object to serialize
    • writeObjectPretty

      public static void writeObjectPretty(@NotNull @NotNull Appendable writer, @NotNull @NotNull com.google.gson.JsonObject object)
      Serializes a JsonObject to the given Appendable using pretty-print formatting.
      Parameters:
      writer - the target to write the JSON to
      object - the object to serialize
    • writeElement

      public static void writeElement(@NotNull @NotNull Appendable writer, @NotNull @NotNull com.google.gson.JsonElement element)
      Serializes a JsonElement to the given Appendable using standard formatting.
      Parameters:
      writer - the target to write the JSON to
      element - the element to serialize
    • writeElementPretty

      public static void writeElementPretty(@NotNull @NotNull Appendable writer, @NotNull @NotNull com.google.gson.JsonElement element)
      Serializes a JsonElement to the given Appendable using pretty-print formatting.
      Parameters:
      writer - the target to write the JSON to
      element - the element to serialize
    • toString

      @NotNull public static @NotNull String toString(@NotNull @NotNull com.google.gson.JsonElement element)
      Serializes a JsonElement to a string using standard formatting.
      Parameters:
      element - the element to serialize
      Returns:
      the JSON string representation
    • toStringPretty

      @NotNull public static @NotNull String toStringPretty(@NotNull @NotNull com.google.gson.JsonElement element)
      Serializes a JsonElement to a pretty-printed string.
      Parameters:
      element - the element to serialize
      Returns:
      the pretty-printed JSON string representation