Annotation Interface FeatureVariant


@Target({METHOD,TYPE}) @Retention(RUNTIME) @Documented public @interface FeatureVariant
Feature Variant Annotation 功能变体注解

Annotation for marking methods as feature variants for A/B testing.

用于标记方法为A/B测试功能变体的注解。

Features | 主要功能:

  • A/B testing support - A/B测试支持
  • Multiple variants - 多变体支持
  • Variant identification - 变体标识

Usage Examples | 使用示例:

@FeatureVariant(feature = "checkout-flow", variant = "A")
public void checkoutFlowA() {
    // Original checkout flow
}

@FeatureVariant(feature = "checkout-flow", variant = "B")
public void checkoutFlowB() {
    // New checkout flow for testing
}

@FeatureVariant(feature = "button-color", variant = "blue", percentage = 50)
public void renderBlueButton() {
    // 50% of users see blue button
}

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 功能键
    Variant identifier (e.g., "A", "B", "control", "experiment") 变体标识符(例如:"A"、"B"、"control"、"experiment")
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Description of the variant 变体描述
    int
    Percentage of traffic for this variant (0-100) 此变体的流量百分比(0-100)
  • Element Details

    • feature

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

      String variant
      Variant identifier (e.g., "A", "B", "control", "experiment") 变体标识符(例如:"A"、"B"、"control"、"experiment")
      Returns:
      variant identifier | 变体标识符
    • percentage

      int percentage
      Percentage of traffic for this variant (0-100) 此变体的流量百分比(0-100)
      Returns:
      traffic percentage | 流量百分比
      Default:
      0
    • description

      String description
      Description of the variant 变体描述
      Returns:
      variant description | 变体描述
      Default:
      ""