Class Feature.Builder

java.lang.Object
cloud.opencode.base.feature.Feature.Builder
Enclosing class:
Feature

public static class Feature.Builder extends Object
Builder for Feature Feature构建器
Since:
JDK 25, opencode-base-feature V1.0.3
Author:
Leon Soo www.LeonSoo.com
  • Constructor Details

    • Builder

      public Builder(String key)
      Create builder with key 使用键创建构建器
      Parameters:
      key - the feature key | 功能键
  • Method Details

    • name

      public Feature.Builder name(String name)
      Set display name 设置显示名称
      Parameters:
      name - the display name | 显示名称
      Returns:
      this builder | 此构建器
    • description

      public Feature.Builder description(String description)
      Set description 设置描述
      Parameters:
      description - the description | 描述
      Returns:
      this builder | 此构建器
    • defaultEnabled

      public Feature.Builder defaultEnabled(boolean enabled)
      Set default enabled state 设置默认启用状态
      Parameters:
      enabled - the default state | 默认状态
      Returns:
      this builder | 此构建器
    • strategy

      public Feature.Builder strategy(EnableStrategy strategy)
      Set enable strategy 设置启用策略
      Parameters:
      strategy - the strategy | 策略
      Returns:
      this builder | 此构建器
    • alwaysOn

      public Feature.Builder alwaysOn()
      Set always on strategy 设置始终启用策略
      Returns:
      this builder | 此构建器
    • alwaysOff

      public Feature.Builder alwaysOff()
      Set always off strategy 设置始终禁用策略
      Returns:
      this builder | 此构建器
    • percentage

      public Feature.Builder percentage(int percent)
      Set percentage strategy 设置百分比策略
      Parameters:
      percent - the percentage (0-100) | 百分比 (0-100)
      Returns:
      this builder | 此构建器
    • forUsers

      public Feature.Builder forUsers(String... userIds)
      Set user list strategy 设置用户列表策略
      Parameters:
      userIds - the allowed user IDs | 允许的用户ID
      Returns:
      this builder | 此构建器
    • forUsers

      public Feature.Builder forUsers(Set<String> userIds)
      Set user list strategy 设置用户列表策略
      Parameters:
      userIds - the allowed user IDs | 允许的用户ID
      Returns:
      this builder | 此构建器
    • metadata

      public Feature.Builder metadata(String key, Object value)
      Add metadata entry 添加元数据条目
      Parameters:
      key - the metadata key | 元数据键
      value - the metadata value | 元数据值
      Returns:
      this builder | 此构建器
    • metadata

      public Feature.Builder metadata(Map<String,Object> metadata)
      Add all metadata from map 从映射添加所有元数据
      Parameters:
      metadata - the metadata map | 元数据映射
      Returns:
      this builder | 此构建器
    • group

      public Feature.Builder group(String group)
      Set feature group 设置功能组
      Parameters:
      group - the group name | 组名称
      Returns:
      this builder | 此构建器
    • expiresAt

      public Feature.Builder expiresAt(Instant expiresAt)
      Set expiration time 设置过期时间
      Parameters:
      expiresAt - the expiration instant | 过期时间点
      Returns:
      this builder | 此构建器
    • expiresAfter

      public Feature.Builder expiresAfter(Duration duration)
      Set expiration as a duration from now 设置从现在开始的过期持续时间
      Parameters:
      duration - the duration until expiration | 到过期的持续时间
      Returns:
      this builder | 此构建器
    • lifecycle

      public Feature.Builder lifecycle(FeatureLifecycle lifecycle)
      Set lifecycle state 设置生命周期状态
      Parameters:
      lifecycle - the lifecycle state | 生命周期状态
      Returns:
      this builder | 此构建器
    • build

      public Feature build()
      Build the feature 构建功能
      Returns:
      new Feature | 新的Feature