Annotation Interface FeatureToggle


@Target({METHOD,TYPE}) @Retention(RUNTIME) @Documented public @interface FeatureToggle
Feature Toggle Annotation 功能开关注解

Annotation for marking methods or types as feature-gated.

用于标记方法或类型为功能门控的注解。

Features | 主要功能:

  • Method-level toggle - 方法级别开关
  • Type-level toggle - 类型级别开关
  • Default value support - 默认值支持

Usage Examples | 使用示例:

@FeatureToggle("dark-mode")
public void renderDarkTheme() {
    // Only executes if dark-mode feature is enabled
}

@FeatureToggle(value = "beta-feature", defaultEnabled = false)
public class BetaService {
    // Class gated by beta-feature flag
}

Security | 安全性:

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

    Required Elements
    Modifier and Type
    Required Element
    Description
    Feature key 功能键
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    boolean
    Default enabled state when feature is not found 功能未找到时的默认启用状态
    Description of the feature 功能描述
  • Element Details

    • value

      String value
      Feature key 功能键
      Returns:
      the feature key | 功能键
    • defaultEnabled

      boolean defaultEnabled
      Default enabled state when feature is not found 功能未找到时的默认启用状态
      Returns:
      default enabled state | 默认启用状态
      Default:
      false
    • description

      String description
      Description of the feature 功能描述
      Returns:
      feature description | 功能描述
      Default:
      ""