TomlValue

sealed class TomlValue

Kotlin representation of a TOML value. A full TOML document is always represented as a TomlValue.Map.

You can either traverse this representation manually, access individual properties using TomlValue.get, or decode the whole thing into a data class of your choice using TomlValue.decode.

TomlValue.from can be used to obtain a TomlValue from an input TOML document in the form of a String, Path, or InputStream.

Types

Bool
Link copied to clipboard
data class Bool(value: Boolean) : TomlValue.Primitive
Companion
Link copied to clipboard
object Companion
Double
Link copied to clipboard
data class Double(value: Double) : TomlValue.Primitive
Integer
Link copied to clipboard
data class Integer(value: Long) : TomlValue.Primitive
List
Link copied to clipboard
data class List(elements: List<TomlValue>) : TomlValue
LocalDate
Link copied to clipboard
data class LocalDate(value: LocalDate) : TomlValue.Primitive
LocalDateTime
Link copied to clipboard
data class LocalDateTime(value: LocalDateTime) : TomlValue.Primitive
LocalTime
Link copied to clipboard
data class LocalTime(value: LocalTime) : TomlValue.Primitive
Map
Link copied to clipboard
data class Map(properties: Map<String, TomlValue>) : TomlValue
OffsetDateTime
Link copied to clipboard
data class OffsetDateTime(value: OffsetDateTime) : TomlValue.Primitive
Primitive
Link copied to clipboard
sealed class Primitive : TomlValue
String
Link copied to clipboard
data class String(value: String) : TomlValue.Primitive

Inheritors

TomlValue
Link copied to clipboard
TomlValue
Link copied to clipboard
TomlValue
Link copied to clipboard

Extensions

decode
Link copied to clipboard
inline fun <T : Any> TomlValue.decode(): T

Decodes the receiver TOML value to the type indicated by type parameter T using the default TOML decoder. If the value can't be decoded into the target type, a TomlException.DecodingError is thrown.

fun <T : Any> TomlValue.decode(type: KType): T

Decodes the receiver TOML value into a value of the type corresponding to the given KType. T and type should correspond to the same type, or the behavior of decode is undefined.

inline fun <T : Any> TomlValue.decode(decoder: TomlDecoder): T

Decodes the receiver TOML value into a value of type T, using the given custom decoder.

fun <T : Any> TomlValue.decode(decoder: TomlDecoder, type: KType): T

Decodes the receiver TOML value into a value of the type corresponding to the given KType, using the given custom decoder. T and type should correspond to the same type, or the behavior of decode is undefined.

get
Link copied to clipboard
inline operator fun <T : Any> TomlValue.get(vararg path: String): T?

Look up the value(s) at the given path in the receiver TOML structure, then decode them into the type given by the type parameter T. If decoding is not possible, a TomlException.DecodingError is thrown. If there is no value at the given path, null is returned.

fun <T> TomlValue.get(targetType: KType, path: List<String>): T?

Look up the value(s) at the given path in the receiver TOML structure, then decode them into the type given by targetKType. targetKType and T should correspond to the same type, or the behavior of get is undefined.

inline fun <T : Any> TomlValue.get(decoder: TomlDecoder, vararg path: String): T?

Look up the value(s) at the given path in the receiver TOML structure, then decode them into the type given by T using the given custom TOML decoder.

fun <T> TomlValue.get(decoder: TomlDecoder, targetType: KType, path: List<String>): T?

Look up the value(s) at the given path in the receiver TOML structure, then decode them into the type given by targetKType using the given custom TOML decoder. targetKType and T should correspond to the same type, or the behavior of get is undefined.