Interface EnableStrategy

All Known Implementing Classes:
AlwaysOffStrategy, AlwaysOnStrategy, CompositeStrategy, ConsistentPercentageStrategy, DateRangeStrategy, EnvironmentStrategy, ExpressionStrategy, PercentageStrategy, TenantAwareStrategy, UserListStrategy
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface EnableStrategy
Enable Strategy Interface 启用策略接口

Interface for feature enablement strategies.

功能启用策略的接口。

Features | 主要功能:

  • Feature evaluation - 功能评估
  • Context-aware decision - 上下文感知决策
  • Composable strategies - 可组合策略

Built-in Strategies | 内置策略:

Usage Examples | 使用示例:

// Custom strategy
EnableStrategy strategy = (feature, context) -> {
    return context.getAttribute("role", "").equals("admin");
};

Feature feature = Feature.builder("admin-feature")
    .strategy(strategy)
    .build();

Security | 安全性:

  • Thread-safe: Implementation-dependent - 线程安全: 取决于实现
  • Null-safe: No - 空值安全: 否
Since:
JDK 25, opencode-base-feature V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    isEnabled(Feature feature, FeatureContext context)
    Determine if the feature is enabled for the given context 确定功能对于给定上下文是否启用
  • Method Details

    • isEnabled

      boolean isEnabled(Feature feature, FeatureContext context)
      Determine if the feature is enabled for the given context 确定功能对于给定上下文是否启用
      Parameters:
      feature - the feature being evaluated | 正在评估的功能
      context - the evaluation context | 评估上下文
      Returns:
      true if enabled | 如果启用返回true