Annotation Interface NotEmpty


@Target(FIELD) @Retention(RUNTIME) public @interface NotEmpty
Declares that a config value must not be empty. The outcome depends on the value kind:
  • Text (String or char): a value that is null or empty after trimming refuses the module at load, or the reload, naming the field (D-01).
  • List, set, map or array (since 6.3.0, #630): a value that a load or reload binds empty - the file holds it empty or null, or every entry failed to bind - is replaced in memory by the field's declared default, and one WARNING names the file, the key, the value kind, the value as written and the default. The module loads. A panel write that would empty the value is refused, like any other constraint violation.
In both cases the config file is never written. The declared default of a list, set, map or array must itself satisfy the field's constraints - be non-empty and inside the field's @Size, if any: a default that does not refuses the module at load as a declaration error naming the field and the constraint, whatever the file holds.

On a value type it cannot check, the module is refused at load, before the file is read, naming the field and the annotation (since 6.3.0, #631; maintainer decision of 2026-10-06). So is this annotation on a field of a config class that is not a @ConfigEntry setting.

It takes effect only on a field that is itself a @ConfigEntry setting of a config class, judged by that field's declared type. A declared type that can hold a value the annotation checks - Object, Serializable, Comparable, CharSequence, Number or another supertype of a checked kind - is accepted, and the value bound at load is checked; only a type that can never hold a checkable value is a declaration error. A bound value of a kind the annotation cannot read (text under @Range, a number under @Pattern) is a violation like any other: the module is refused at load, and a reload is refused with the running values kept. On a field of a value type, a nested class or anything a converter produces it is never checked and not reported (maintainer decision of 2026-10-06): validate such fields in the module's converter.

See Also: