Interface CaptchaGenerator

All Known Implementing Classes:
ArithmeticCaptchaGenerator, AudioCaptchaGenerator, ChineseCaptchaGenerator, ClickCaptchaGenerator, GifCaptchaGenerator, ImageCaptchaGenerator, ImageSelectCaptchaGenerator, JigsawCaptchaGenerator, PowCaptchaGenerator, RotateCaptchaGenerator, SliderCaptchaGenerator, SpecCaptchaGenerator, TestCaptchaGenerator

Captcha Generator - Sealed interface for CAPTCHA generation 验证码生成器 - 验证码生成的密封接口

This sealed interface defines the contract for CAPTCHA generators. All generators must implement this interface.

此密封接口定义了验证码生成器的契约。 所有生成器都必须实现此接口。

Features | 主要功能:

  • Sealed interface ensuring all generators are known at compile time - 密封接口确保编译时已知所有生成器
  • Factory method for type-based generator creation - 基于类型的生成器创建工厂方法
  • Convenience factory methods for common types - 常用类型的便捷工厂方法

Usage Examples | 使用示例:

CaptchaGenerator generator = CaptchaGenerator.forType(CaptchaType.ALPHANUMERIC);
Captcha captcha = generator.generate(CaptchaConfig.defaults());

Security | 安全性:

  • Thread-safe: Implementation-dependent - 线程安全: 取决于实现
  • Null-safe: No (config must be non-null) - 空值安全: 否(config 不能为空)
Since:
JDK 25, opencode-base-captcha V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Method Details

    • generate

      default Captcha generate()
      Generates a CAPTCHA with default configuration. 使用默认配置生成验证码。
      Returns:
      the generated CAPTCHA | 生成的验证码
    • generate

      Captcha generate(CaptchaConfig config)
      Generates a CAPTCHA with the specified configuration. 使用指定配置生成验证码。
      Parameters:
      config - the configuration | 配置
      Returns:
      the generated CAPTCHA | 生成的验证码
    • getType

      CaptchaType getType()
      Gets the supported CAPTCHA type. 获取支持的验证码类型。
      Returns:
      the CAPTCHA type | 验证码类型
    • forType

      static CaptchaGenerator forType(CaptchaType type)
      Creates a generator for the specified type. 为指定类型创建生成器。
      Parameters:
      type - the CAPTCHA type | 验证码类型
      Returns:
      the generator | 生成器
    • numeric

      static CaptchaGenerator numeric()
      Creates a numeric CAPTCHA generator. 创建数字验证码生成器。
      Returns:
      the generator | 生成器
    • alpha

      static CaptchaGenerator alpha()
      Creates an alphabetic CAPTCHA generator. 创建字母验证码生成器。
      Returns:
      the generator | 生成器
    • alphanumeric

      static CaptchaGenerator alphanumeric()
      Creates an alphanumeric CAPTCHA generator. 创建字母数字验证码生成器。
      Returns:
      the generator | 生成器
    • arithmetic

      static CaptchaGenerator arithmetic()
      Creates an arithmetic CAPTCHA generator. 创建算术验证码生成器。
      Returns:
      the generator | 生成器
    • chinese

      static CaptchaGenerator chinese()
      Creates a Chinese CAPTCHA generator. 创建中文验证码生成器。
      Returns:
      the generator | 生成器
    • gif

      static CaptchaGenerator gif()
      Creates a GIF CAPTCHA generator. 创建 GIF 验证码生成器。
      Returns:
      the generator | 生成器
    • audio

      static CaptchaGenerator audio()
      Creates an audio CAPTCHA generator. 创建音频验证码生成器。
      Returns:
      the generator | 生成器
    • pow

      static CaptchaGenerator pow()
      Creates a Proof-of-Work CAPTCHA generator. 创建工作量证明验证码生成器。
      Returns:
      the generator | 生成器