Class UserListStrategy
java.lang.Object
cloud.opencode.base.feature.strategy.UserListStrategy
- All Implemented Interfaces:
EnableStrategy
User List Strategy
用户列表策略
Strategy that enables feature for specific users.
为特定用户启用功能的策略。
Features | 主要功能:
- User whitelist - 用户白名单
- Beta user targeting - Beta用户定向
- VIP user features - VIP用户功能
Usage Examples | 使用示例:
// Using builder shortcut
Feature feature = Feature.builder("beta-feature")
.forUsers("user1", "user2", "user3")
.build();
// Using strategy directly
Feature feature = Feature.builder("vip-feature")
.strategy(new UserListStrategy(Set.of("vip1", "vip2")))
.build();
Security | 安全性:
- Thread-safe: Yes - 线程安全: 是
- Null-safe: Partial (validates inputs) - 空值安全: 部分(验证输入)
- Since:
- JDK 25, opencode-base-feature V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionUserListStrategy(Set<String> allowedUsers) Create user list strategy 创建用户列表策略 -
Method Summary
Modifier and TypeMethodDescriptionGet the set of allowed users 获取允许的用户集合booleanisEnabled(Feature feature, FeatureContext context) Check if user is in the allowed list 检查用户是否在允许列表中booleanisUserAllowed(String userId) Check if a specific user is allowed 检查特定用户是否被允许toString()
-
Constructor Details
-
UserListStrategy
-
-
Method Details
-
isEnabled
Check if user is in the allowed list 检查用户是否在允许列表中- Specified by:
isEnabledin interfaceEnableStrategy- Parameters:
feature- the feature | 功能context- the context | 上下文- Returns:
- true if user is allowed | 如果用户被允许返回true
-
getAllowedUsers
-
isUserAllowed
Check if a specific user is allowed 检查特定用户是否被允许- Parameters:
userId- the user ID | 用户ID- Returns:
- true if allowed | 如果允许返回true
-
toString
-