Record Class ProviderConfig

java.lang.Object
java.lang.Record
cloud.opencode.base.sms.config.ProviderConfig
Record Components:
name - the provider name | 服务商名称
endpoint - the API endpoint | API端点
apiVersion - the API version | API版本
region - the region | 区域
timeout - the request timeout | 请求超时
connectTimeout - the connection timeout | 连接超时
maxRetries - the max retry attempts | 最大重试次数
sdkAppId - the SDK app ID (for Tencent) | SDK应用ID(腾讯云)
extraOptions - extra provider-specific options | 额外服务商特定选项

public record ProviderConfig(String name, String endpoint, String apiVersion, String region, Duration timeout, Duration connectTimeout, int maxRetries, String sdkAppId, Map<String,String> extraOptions) extends Record
Provider Config - SMS provider specific configuration 服务商配置 - 短信服务商特定配置

Configuration for specific SMS provider settings such as endpoints, API versions, and provider-specific options.

特定短信服务商设置的配置,如端点、API版本和服务商特定选项。

Features | 主要功能:

  • Provider-specific endpoint and API version config - 服务商特定端点和API版本配置
  • Timeout and retry configuration - 超时和重试配置
  • Builder pattern with defaults - 带默认值的构建器模式
  • Extra options map for extensibility - 额外选项映射用于扩展

Usage Example | 使用示例:

// Aliyun SMS configuration
ProviderConfig aliConfig = ProviderConfig.builder()
    .name("aliyun")
    .endpoint("dysmsapi.aliyuncs.com")
    .apiVersion("2017-05-25")
    .region("cn-hangzhou")
    .maxRetries(3)
    .build();

// Tencent Cloud SMS configuration
ProviderConfig tencentConfig = ProviderConfig.builder()
    .name("tencent")
    .endpoint("sms.tencentcloudapi.com")
    .apiVersion("2021-01-11")
    .sdkAppId("1400xxxxx")
    .build();

Security | 安全性:

  • Thread-safe: Yes (immutable record) - 线程安全: 是(不可变记录)
  • Null-safe: Yes (defaults applied in compact constructor) - 空值安全: 是(紧凑构造器中应用默认值)
Since:
JDK 25, opencode-base-sms V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Constructor Details

  • Method Details

    • builder

      public static ProviderConfig.Builder builder()
      Creates a builder. 创建构建器。
      Returns:
      new builder | 新构建器
    • aliyun

      public static ProviderConfig aliyun(String region)
      Creates a default Aliyun configuration. 创建默认阿里云配置。
      Parameters:
      region - the region | 区域
      Returns:
      the config | 配置
    • tencent

      public static ProviderConfig tencent(String sdkAppId)
      Creates a default Tencent configuration. 创建默认腾讯云配置。
      Parameters:
      sdkAppId - the SDK app ID | SDK应用ID
      Returns:
      the config | 配置
    • huawei

      public static ProviderConfig huawei(String region)
      Creates a default Huawei configuration. 创建默认华为云配置。
      Parameters:
      region - the region | 区域
      Returns:
      the config | 配置
    • getOption

      public String getOption(String key)
      Gets an extra option value. 获取额外选项值。
      Parameters:
      key - the option key | 选项键
      Returns:
      the value or null | 值或null
    • getOption

      public String getOption(String key, String defaultValue)
      Gets an extra option value with default. 获取带默认值的额外选项值。
      Parameters:
      key - the option key | 选项键
      defaultValue - the default value | 默认值
      Returns:
      the value or default | 值或默认值
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • name

      public String name()
      Returns the value of the name record component.
      Returns:
      the value of the name record component
    • endpoint

      public String endpoint()
      Returns the value of the endpoint record component.
      Returns:
      the value of the endpoint record component
    • apiVersion

      public String apiVersion()
      Returns the value of the apiVersion record component.
      Returns:
      the value of the apiVersion record component
    • region

      public String region()
      Returns the value of the region record component.
      Returns:
      the value of the region record component
    • timeout

      public Duration timeout()
      Returns the value of the timeout record component.
      Returns:
      the value of the timeout record component
    • connectTimeout

      public Duration connectTimeout()
      Returns the value of the connectTimeout record component.
      Returns:
      the value of the connectTimeout record component
    • maxRetries

      public int maxRetries()
      Returns the value of the maxRetries record component.
      Returns:
      the value of the maxRetries record component
    • sdkAppId

      public String sdkAppId()
      Returns the value of the sdkAppId record component.
      Returns:
      the value of the sdkAppId record component
    • extraOptions

      public Map<String,String> extraOptions()
      Returns the value of the extraOptions record component.
      Returns:
      the value of the extraOptions record component