VitalConfig

abstract class VitalConfig : VitalHasInfo

Defines a config within the Vital-Framework. A config class defines the structure and datatypes of a singular configuration file stored on the filesystem. It's data can be loaded from the filesystem into the class to expose a developer-friendly api to access it.

Each field annotated with VitalConfig.Property will be defined as a valid property for serialization and deserialization.

The consuming class must be annotated with VitalConfig.Info.

@VitalConfig.Info(
name = "my-vital-config.yaml",
processor = VitalYAMLConfigProcessor.class
)
public class MyVitalConfig extends VitalConfig {
@Property(types = {String.class})
private String myString;

@Property(types = {String.class})
private List<String> myStringList;

@Property(types = {String.class, Long.class})
private Map<String, Long> myStringLongMap;
}

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard
object Companion
Link copied to clipboard
@Component
@Target(allowedTargets = [AnnotationTarget.CLASS])
annotation class Info(val name: String, val processor: KClass<out VitalConfig.Processor<*, Any>>)

Defines the info for a VitalConfig.

Link copied to clipboard
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.

Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.FIELD])
annotation class Property(val types: KClass<*>)

This annotation marks a Field as a property that can automatically be injected by a VitalConfig. Use this annotation inside a VitalConfig implementer or any other class than is used as a value in a VitalConfig implementer.

Properties

Link copied to clipboard
val file: Path
Link copied to clipboard
Link copied to clipboard
val logger: Logger
Link copied to clipboard

Functions

Link copied to clipboard
open fun <T : Annotation> getInfo(type: Class<T>): T
Link copied to clipboard
fun load(inputStream: InputStream)

Loads this config from the given inputStream. This function will load the serialized content via the defined Info.processor and initialize this class's fields.

Link copied to clipboard
fun save()

Saves this config by writing its field values to the defined file in path Info.name.