Required

@Target(allowedTargets = [AnnotationTarget.FIELD])
annotation class Required(val soft: Boolean = false, val named: String = "")

Marks a field as required in the configuration.

If the field is missing or blank in the loaded configuration, an error will be reported. If soft is true, the absence will be logged as a warning instead of throwing an error.

This annotation also allows specifying a custom name to report in logs via named.

Example:

@Required
String apiKey;

@Required(soft = true, named = "logChannelId")
String logChannel;

Properties

Link copied to clipboard

an optional name to use in logs; defaults to the field name

Link copied to clipboard
val soft: Boolean = false

whether this is a soft requirement (log warning instead of error)