java.lang.Object
org.spongepowered.plugin.metadata.builtin.MetadataParser

public final class MetadataParser extends Object
  • Method Details

    • gson

      public static Gson gson()
    • warnings

      public static Set<String> warnings()
      Returns all warnings generated by (de)serializers so that the platform may log them when appropriate.
      Returns:
      The warnings
    • addWarning

      public static void addWarning(String warning)
      Adds a warning generated by a (de)serializer so that the platform may log it later.
      Parameters:
      warning - The warning
    • read

      public static MetadataContainer read(Path path) throws IOException
      Reads a container from a given path using the default deserializer (retrieved from gson()).
      Parameters:
      path - The path
      Returns:
      The container
      Throws:
      IOException - if the container fails to be read
    • read

      public static MetadataContainer read(Path path, Gson gson) throws IOException
      Reads a container from a given path with configured deserializer.

      To get a standard deserializer, gson() is available.

      Parameters:
      path - The path
      gson - The deserializer
      Returns:
      The container
      Throws:
      IOException - if the container fails to be read
    • read

      public static MetadataContainer read(Reader reader) throws IOException
      Reads a container from a given reader using the default deserializer (retrieved from gson()).
      Parameters:
      reader - The reader
      Returns:
      The container
      Throws:
      IOException - if the container fails to be read
    • read

      public static MetadataContainer read(Reader reader, Gson gson) throws IOException
      Reads a container from a given reader with configured deserializer.

      To get a standard deserializer, gson() is available.

      Parameters:
      reader - The reader
      gson - The deserializer
      Returns:
      The container
      Throws:
      IOException - if the container fails to deserialize
    • write

      public static void write(Path path, MetadataContainer container, boolean indent) throws IOException
      Writes a container to the given path using the default deserializer (retrieved from gson()).
      Parameters:
      path - The path
      container - The container
      indent - True to indent (pretty print) the resulting JSON, false if not
      Throws:
      IOException - If the container fails to serialize
    • write

      public static void write(Path path, MetadataContainer container, Gson gson, boolean indent) throws IOException
      Writes a container to the given path using the configured serializer.

      To get a standard serializer, gson() is available.

      Parameters:
      path - The path
      container - The container
      gson - The serializer
      indent - True to indent (pretty print) the resulting JSON, false if not
      Throws:
      IOException - If the container fails to serialize
    • write

      public static void write(Writer writer, MetadataContainer container, boolean indent) throws IOException
      Writes a container to the given path using the default deserializer (retrieved from gson()).
      Parameters:
      writer - The writer
      container - The container
      indent - True to indent (pretty print) the resulting JSON, false if not
      Throws:
      IOException - If the container fails to serialize
    • write

      public static void write(Writer writer, MetadataContainer container, Gson gson, boolean indent) throws IOException
      Writes a container to the given path using the configured serializer.

      To get a standard serializer, gson() is available.

      Parameters:
      writer - The writer
      container - The container
      gson - The serializer
      indent - True to indent (pretty print) the resulting JSON, false if not
      Throws:
      IOException - If the container fails to serialize