FieldDescriptor

class FieldDescriptor<T>(val propertyName: String, val typeName: String, val secret: Boolean, val default: T?, val hasDefault: Boolean, val customKey: String? = null, val convert: (String) -> T, val convertChildren: (Map<String, String>) -> T? = null, val validate: (T) -> String?? = null)(source)

Describes one config field for ConfigLoader.resolve. Built by generated code.

Constructors

Link copied to clipboard
constructor(propertyName: String, typeName: String, secret: Boolean, default: T?, hasDefault: Boolean, customKey: String? = null, convert: (String) -> T, convertChildren: (Map<String, String>) -> T? = null, validate: (T) -> String?? = null)

Properties

Link copied to clipboard
val convert: (String) -> T

Converts the raw text; throws on invalid input.

Link copied to clipboard

Builds the value from ConfigSource.children when the key itself is absent (Map fields).

Link copied to clipboard

The @Key name, used instead of a derived key.

Link copied to clipboard
val default: T?

The value used when no source has the key, if hasDefault.

Link copied to clipboard

Whether the field is optional: it has a default or is nullable.

Link copied to clipboard

The property name in the spec, e.g. maxPoolSize.

Link copied to clipboard

True for a @Secret field, whose value is shown as ***.

Link copied to clipboard
Link copied to clipboard
val validate: (T) -> String??

Returns an error message when a converted value breaks a validation annotation.