Processor

interface Processor<S, out T>

Defines a processor that can serialize and deserialize content for a VitalConfig. Implementation classes should be used in Info.processor.

Inheritors

Properties

Link copied to clipboard
abstract val data: S

The data object this processor will use to serialize the content. E.g., java.util.Properties for a processor that can write and load .properties configs.

Functions

Link copied to clipboard
abstract fun deserialize(serializedContent: Map<String, T>, type: Class<*>): Any?

Deserializes the given serializedContent to the given type returns an initialized instance of it.

Link copied to clipboard
abstract fun load(inputStream: InputStream, clazz: Class<*>): Map<String, T>

Loads the given inputStream into the data of this config and returns a Map of all properties to value mappings.

Link copied to clipboard
abstract fun read(key: String): T?

Reads a single value for the given key from the data of this config.

abstract fun read(key: String, def: T): T?

Reads a single value for the given key from the data of this config. If no value was found, this function will return the given def.

Link copied to clipboard
abstract fun save(serializedContent: Map<String, T>): String

Saves the given serializedContent to the data of this config.

Link copied to clipboard
abstract fun serialize(instance: Any): Map<String, T>

Serializes the content of the given instance to a Map where each entry is the name and value for each Field of the given instance.

Link copied to clipboard
abstract fun write(instance: Any)

Writes the given instance to the file of this config. E.g., the VitalPropertiesConfigProcessor first serialized its content via serialize and then calls write with it.

abstract fun write(serializedContent: Map<String, T>)

Writes the given serializedContent to the file of this config.

abstract fun write(key: String, value: T)

Writes the given value to the property with the given key to the data of this config.