Annotation Interface NestedConfig


@Target(FIELD) @Retention(RUNTIME) public @interface NestedConfig
Nested Configuration Annotation 嵌套配置注解

Marks a field as a nested configuration object.

将字段标记为嵌套配置对象。

Features | 主要功能:

  • Nested configuration binding - 嵌套配置绑定
  • Optional custom prefix - 可选的自定义前缀
  • Recursive binding support - 递归绑定支持

Usage Examples | 使用示例:

@ConfigProperties(prefix = "application")
public class AppConfig {
    private String name;

    @NestedConfig  // Uses field name as sub-prefix
    private ServerConfig server;  // application.server.*

    @NestedConfig(prefix = "db")  // Custom prefix
    private DatabaseConfig database;  // application.db.*
}

public class ServerConfig {
    private int port;      // application.server.port
    private String host;   // application.server.host
}

Security | 安全性:

  • Thread-safe: Yes (immutable) - 线程安全: 是(不可变)
  • Null-safe: N/A - 空值安全: 不适用
Since:
JDK 25, opencode-base-config V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Custom prefix for nested configuration 嵌套配置的自定义前缀
  • Element Details

    • prefix

      String prefix
      Custom prefix for nested configuration 嵌套配置的自定义前缀

      If empty, uses the field name as the sub-prefix.

      如果为空,使用字段名作为子前缀。

      Returns:
      nested configuration prefix | 嵌套配置前缀
      Default:
      ""