Annotation Interface Section


@Retention(RUNTIME) @Target(FIELD) public @interface Section
Marks a field to be serialized as a nested section/table in the configuration file.

The annotated field must be of a POJO type (not a primitive or ConfigurablePojo). Fields within the nested POJO can use Key and Comment annotations as usual. Section POJOs may themselves contain @Section fields — nesting is recursive (depth-capped at 16 to guard against cyclic references).

Format-specific behavior:

  • YAML: Rendered as nested indented block
  • TOML: Rendered as [table] section ([parent.child] when nested)
  • JSON: Rendered as nested object
  • Properties: Rendered as dotted key prefix (section.key)

Example:


 @Comment("Database connection settings")
 @Section("database")
 private DatabaseSettings database = new DatabaseSettings();

 public class DatabaseSettings {
     @Key("host")
     @Comment("Database hostname")
     private String host = "localhost";

     @Key("port")
     private int port = 5432;
 }
 

Note: Section fields are serialized after all root-level @Key fields. A @Key field following a @Section does NOT belong to that section.

See Also:
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    The section/table name in the configuration file.
  • Element Details

    • value

      String value
      The section/table name in the configuration file. If empty, the name is derived from the field's Key annotation, or the field name itself if no @Key is present.
      Default:
      ""