Package dev.denux.dtp
Class DTP
java.lang.Object
dev.denux.dtp.DTP
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> T
fromToml
(TomlReader tomlReader, Class<T> clazzOfT) Serializes the given toml to a new instance of the given class.<T> T
Serializes the given toml to a new instance of the given class.<T> T
Serializes the given toml to a new instance of the given class.toToml
(TomlWriter writer) Deserializes the givenObject
to a string that represents a toml file.Deserializes the givenObject
to a string that represents a toml file.void
writeTomlToFile
(Object source, File file, OpenOption... openOptions) void
writeTomlToFile
(Object source, Path path, OpenOption... openOptions)
-
Constructor Details
-
DTP
public DTP()
-
-
Method Details
-
fromToml
Serializes the given toml to a new instance of the given class. -
fromToml
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
- TheClass
of the object that we will instantiate.- Returns:
- the object or null if there was an exception while reading or serializing.
-
fromToml
Serializes the given toml to a new instance of the given class.- Type Parameters:
T
- The object that will be returned.- Parameters:
tomlReader
- theTomlReader
that reads the toml file and formats it to make it easier for theTomlParser
.clazzOfT
- TheClass
of the object that we will instantiate.- Returns:
- the object or null if there was an exception while reading or serializing.
-
toToml
Deserializes the givenObject
to a string that represents a toml file. -
toToml
Deserializes the givenObject
to a string that represents a toml file.- Parameters:
writer
- theTomlWriter
that writes an object to aString
.- 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 - Parameters:
source
- theObject
you want to deserialize.file
- theFile
you want to write to.openOptions
-OpenOption
s 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 - Parameters:
source
- theObject
you want to deserialize.path
- thePath
you want to write theFile
to.openOptions
-OpenOption
s 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 givenObject
could not be deserialized to a toml string.
-