config / org.apache.tuweni.config / SchemaBuilder

SchemaBuilder

class SchemaBuilder (source)

This interface allows customers to determine a schema to associate with a configuration to validate the entries read from configuration files, and provide default values if no value is present in the configuration file.

Functions

addBoolean

fun addBoolean(key: String, defaultValue: Boolean?, description: String?, validator: PropertyValidator<in Boolean>?): SchemaBuilder

Add a boolean property to the schema.

Even if no validator is provided, the schema will validate that the configuration property, if present, contains a boolean.

If a defaultValue is provided, then the provided validator, if any, will only be invoked if the value is present (i.e. it will not be provided a null value to validate).

addDefault

fun addDefault(key: String, value: Any): SchemaBuilder

Provide a default value for a property.

Invoking this method with the same key as a previous invocation will replace the default value for that key.

addDouble

fun addDouble(key: String, defaultValue: Double?, description: String?, validator: PropertyValidator<in Double>?): SchemaBuilder

Add a double property to the schema.

Even if no validator is provided, the schema will validate that the configuration property, if present, contains a double.

If a defaultValue is provided, then the provided validator, if any, will only be invoked if the value is present (i.e. it will not be provided a null value to validate).

addInteger

fun addInteger(key: String, defaultValue: Int?, description: String?, validator: PropertyValidator<in Int>?): SchemaBuilder

Add an integer property to the schema.

Even if no validator is provided, the schema will validate that the configuration property, if present, contains an integer.

If a defaultValue is provided, then the provided validator, if any, will only be invoked if the value is present (i.e. it will not be provided a null value to validate).

addListOfBoolean

fun addListOfBoolean(key: String, defaultValue: MutableList<Boolean>?, description: String?, validator: PropertyValidator<in MutableList<Boolean>>?): SchemaBuilder

Add a list-of-booleans property to the schema.

Even if no validator is provided, the schema will validate that the configuration property, if present, contains a list of booleans without any null values.

If a defaultValue is provided, then the provided validator, if any, will only be invoked if the value is present (i.e. it will not be provided a null value to validate).

addListOfDouble

fun addListOfDouble(key: String, defaultValue: MutableList<Double>?, description: String?, validator: PropertyValidator<in MutableList<Double>>?): SchemaBuilder

Add a list-of-doubles property to the schema.

Even if no validator is provided, the schema will validate that the configuration property, if present, contains a list of doubles without any null values.

If a defaultValue is provided, then the provided validator, if any, will only be invoked if the value is present (i.e. it will not be provided a null value to validate).

addListOfInteger

fun addListOfInteger(key: String, defaultValue: MutableList<Int>?, description: String?, validator: PropertyValidator<in MutableList<Int>>?): SchemaBuilder

Add a list-of-integers property to the schema.

Even if no validator is provided, the schema will validate that the configuration property, if present, contains a list of integers without any null values.

If a defaultValue is provided, then the provided validator, if any, will only be invoked if the value is present (i.e. it will not be provided a null value to validate).

addListOfLong

fun addListOfLong(key: String, defaultValue: MutableList<Long>?, description: String?, validator: PropertyValidator<in MutableList<Long>>?): SchemaBuilder

Add a list-of-longs property to the schema.

Even if no validator is provided, the schema will validate that the configuration property, if present, contains a list of longs without any null values.

If a defaultValue is provided, then the provided validator, if any, will only be invoked if the value is present (i.e. it will not be provided a null value to validate).

addListOfMap

fun addListOfMap(key: String, defaultValue: MutableList<MutableMap<String, Any>>?, description: String?, validator: PropertyValidator<in MutableList<MutableMap<String, Any>>>?): SchemaBuilder

Add a list-of-maps property to the schema.

Even if no validator is provided, the schema will validate that the configuration property, if present, contains a list of maps without any null values.

If a defaultValue is provided, then the provided validator, if any, will only be invoked if the value is present (i.e. it will not be provided a null value to validate).

addListOfString

fun addListOfString(key: String, defaultValue: MutableList<String>?, description: String?, validator: PropertyValidator<in MutableList<String>>?): SchemaBuilder

Add a list-of-strings property to the schema.

Even if no validator is provided, the schema will validate that the configuration property, if present, contains a list of strings without any null values.

If a defaultValue is provided, then the provided validator, if any, will only be invoked if the value is present (i.e. it will not be provided a null value to validate).

addLong

fun addLong(key: String, defaultValue: Long?, description: String?, validator: PropertyValidator<in Long>?): SchemaBuilder

Add a long property to the schema.

Even if no validator is provided, the schema will validate that the configuration property, if present, contains a long.

If a defaultValue is provided, then the provided validator, if any, will only be invoked if the value is present (i.e. it will not be provided a null value to validate).

addString

fun addString(key: String, defaultValue: String?, description: String?, validator: PropertyValidator<in String>?): SchemaBuilder

Add a string property to the schema.

Even if no validator is provided, the schema will validate that the configuration property, if present, contains a string.

If a defaultValue is provided, then the provided validator, if any, will only be invoked if the value is present (i.e. it will not be provided a null value to validate).

create

static fun create(): SchemaBuilder

Get a new builder for a schema.

documentProperty

fun documentProperty(key: String, description: String): SchemaBuilder

Provide documentation for a property.

Invoking this method with the same key as a previous invocation will replace the description for that key.

toSchema

fun toSchema(): Schema

Return the Schema constructed by this builder.

validateConfiguration

fun validateConfiguration(validator: ConfigurationValidator): SchemaBuilder

Add a configuration validator to the schema.

Multiple validators can be provided by invoking this method multiple times.

validateProperty

fun validateProperty(key: String, validator: PropertyValidator<Any>): SchemaBuilder

Add a property validation to this schema.

Multiple validators can be provided for the same key by invoking this method multiple times.