Properties

Transforms a Serializable class' properties into a single flat Map consisting of string keys and primitive type values, and vice versa.

If the given class has non-primitive property d of arbitrary type D, D values are inserted into the same map; keys for such values are prefixed with string d.:

@Serializable
class Data(val property1: String)

@Serializable
class DataHolder(val data: Data, val property2: String)

val map = Properties.store(DataHolder(Data("value1"), "value2"))
// map contents will be the following:
// property2 = value2
// data.property1 = value1

If the given class has a List property l, each value from the list would be prefixed with l.N., where N is an index for a particular value. Map is treated as a [key,value,...] list.

sealed class Properties : SerialFormat

Parameters

serializersModule

A SerializersModule which should contain registered serializers for Contextual and Polymorphic serialization, if you have any.

Types

Default
Link copied to clipboard
common

A Properties instance that can be used as default and does not have any SerializersModule installed.

object Default : Properties

Functions

decodeFromMap
Link copied to clipboard
common

Decodes properties from the given map to a value of type T using the given deserializer. T may contain properties of nullable types; they will be filled by non-null values from the map, if present.

fun <T> decodeFromMap(deserializer: DeserializationStrategy<T>, map: Map<String, Any>): T
decodeFromStringMap
Link copied to clipboard
common

Decodes properties from the given map to a value of type T using the given deserializer. String values are converted to respective primitive types using default conversion methods. T may contain properties of nullable types; they will be filled by non-null values from the map, if present.

fun <T> decodeFromStringMap(deserializer: DeserializationStrategy<T>, map: Map<String, String>): T
encodeToMap
Link copied to clipboard
common

Encodes properties from the given value to a map using the given serializer. null values are omitted from the output.

fun <T> encodeToMap(serializer: SerializationStrategy<T>, value: T): Map<String, Any>
encodeToStringMap
Link copied to clipboard
common

Encodes properties from the given value to a map using the given serializer. Converts all primitive types to String using toString method. null values are omitted from the output.

fun <T> encodeToStringMap(serializer: SerializationStrategy<T>, value: T): Map<String, String>
equals
Link copied to clipboard
common
open operator override fun equals(other: Any?): Boolean
hashCode
Link copied to clipboard
common
open override fun hashCode(): Int
toString
Link copied to clipboard
common
open override fun toString(): String

Properties

serializersModule
Link copied to clipboard
common

A SerializersModule which should contain registered serializers for Contextual and Polymorphic serialization, if you have any.

open override val serializersModule: SerializersModule

Inheritors

Properties
Link copied to clipboard
common

Extensions

decodeFromMap
Link copied to clipboard
common

Decodes properties from given map, assigns them to an object using serializer for reified type T and returns this object. T may contain properties of nullable types; they will be filled by non-null values from the map, if present.

inline fun <T> Properties.decodeFromMap(map: Map<String, Any>): T
decodeFromStringMap
Link copied to clipboard
common

Decodes properties from given map, assigns them to an object using serializer for reified type T and returns this object. String values are converted to respective primitive types using default conversion methods. T may contain properties of nullable types; they will be filled by non-null values from the map, if present.

inline fun <T> Properties.decodeFromStringMap(map: Map<String, String>): T
encodeToMap
Link copied to clipboard
common

Encodes properties from given value to a map using serializer for reified type T and returns this map. null values are omitted from the output.

inline fun <T> Properties.encodeToMap(value: T): Map<String, Any>
encodeToStringMap
Link copied to clipboard
common

Encodes properties from given value to a map using serializer for reified type T and returns this map. Converts all primitive types to String using toString method. null values are omitted from the output.

inline fun <T> Properties.encodeToStringMap(value: T): Map<String, String>