Package dev.denux.dtp

Class DTP

java.lang.Object
dev.denux.dtp.DTP

public class DTP extends Object
  • Constructor Details

    • DTP

      public DTP()
  • Method Details

    • fromToml

      @Nullable public <T> T fromToml(@Nonnull Reader toml, @Nonnull Class<T> clazzOfT)
      Serializes the given toml to a new instance of the given class.
      Type Parameters:
      T - The object that will be returned.
      Parameters:
      toml - The Reader that reads the toml file.
      clazzOfT - The Class of the object that we will instantiate.
      Returns:
      the object or null if there was an exception while reading or serializing.
    • fromToml

      @Nullable public <T> T fromToml(@Nonnull String tomlString, @Nonnull Class<T> clazzOfT)
      Serializes the given toml to a new instance of the given class.
      Type Parameters:
      T - The object that will be returned.
      Parameters:
      tomlString - The string that represents a toml file.
      clazzOfT - The Class of the object that we will instantiate.
      Returns:
      the object or null if there was an exception while reading or serializing.
    • fromToml

      @Nullable public <T> T fromToml(@Nonnull TomlReader tomlReader, @Nonnull Class<T> clazzOfT)
      Serializes the given toml to a new instance of the given class.
      Type Parameters:
      T - The object that will be returned.
      Parameters:
      tomlReader - the TomlReader that reads the toml file and formats it to make it easier for the TomlParser.
      clazzOfT - The Class of the object that we will instantiate.
      Returns:
      the object or null if there was an exception while reading or serializing.
    • toToml

      @Nullable public String toToml(@Nonnull Object source)
      Deserializes the given Object to a string that represents a toml file.
      Parameters:
      source - the Object you want to deserialize.
      Returns:
      the String or null if there was an exception while writing.
    • toToml

      @Nullable public String toToml(@Nonnull TomlWriter writer)
      Deserializes the given Object to a string that represents a toml file.
      Parameters:
      writer - the TomlWriter that writes an object to a String.
      Returns:
      the String or null if there was an exception while writing.
    • writeTomlToFile

      public void writeTomlToFile(@Nonnull Object source, @Nonnull File file, @Nullable OpenOption... openOptions) throws IOException
      Deserializes the given Object and writes it to the given File.
      Parameters:
      source - the Object you want to deserialize.
      file - the File you want to write to.
      openOptions - OpenOptions that describes how an existing file should be handled.
      Throws:
      IOException - is thrown when the file could not be written.
    • writeTomlToFile

      public void writeTomlToFile(@Nonnull Object source, @Nonnull Path path, @Nullable OpenOption... openOptions) throws IOException
      Deserializes the given Object and writes it to the given Path.
      Parameters:
      source - the Object you want to deserialize.
      path - the Path you want to write the File to.
      openOptions - OpenOptions that describes how an existing file should be handled.
      Throws:
      IOException - is thrown when the file could not be written.
      NullPointerException - is thrown if the given Object could not be deserialized to a toml string.