Class OpenIllegalStateException

All Implemented Interfaces:
Serializable

public class OpenIllegalStateException extends OpenException
Illegal State Exception - Object state validation exception 状态异常 - 对象状态验证异常

Thrown when object state does not meet operation preconditions. Replaces IllegalStateException.

当对象状态不满足操作的前置条件时抛出此异常。替代 IllegalStateException,提供统一的异常处理。

Features | 主要功能:

  • Not initialized check (notInitialized) - 未初始化检查
  • Already closed check (alreadyClosed) - 已关闭检查
  • Already exists check (alreadyExists) - 已存在检查
  • Not found check (notFound) - 未找到检查
  • Invalid state check (invalidState) - 无效状态检查

Usage Examples | 使用示例:

if (!initialized) {
    throw new OpenIllegalStateException("Component not initialized");
}

// Static factory methods - 静态工厂方法
throw OpenIllegalStateException.notInitialized("CacheManager");
throw OpenIllegalStateException.alreadyClosed("Connection");
throw OpenIllegalStateException.notFound("User", userId);

Security | 安全性:

  • Thread-safe: Yes (immutable) - 线程安全: 是 (不可变)
  • Serializable: Yes - 可序列化: 是
Since:
JDK 25, opencode-base-core V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Constructor Details

    • OpenIllegalStateException

      public OpenIllegalStateException(String message)
      Creates 创建状态异常
      Parameters:
      message - the value | 异常消息
    • OpenIllegalStateException

      public OpenIllegalStateException(String message, Throwable cause)
      Creates 创建状态异常(带原因)
      Parameters:
      message - the value | 异常消息
      cause - the value | 原始异常
  • Method Details

    • notInitialized

      public static OpenIllegalStateException notInitialized(String componentName)
      Creates 创建"未初始化"异常
      Parameters:
      componentName - the value | 组件名
      Returns:
      the result | 异常实例
    • alreadyClosed

      public static OpenIllegalStateException alreadyClosed(String resourceName)
      Creates 创建"已关闭"异常
      Parameters:
      resourceName - the value | 资源名
      Returns:
      the result | 异常实例
    • alreadyExists

      public static OpenIllegalStateException alreadyExists(String itemName, Object key)
      Creates 创建"已存在"异常
      Parameters:
      itemName - the value | 项目名
      key - the key | 键
      Returns:
      the result | 异常实例
    • notFound

      public static OpenIllegalStateException notFound(String itemName, Object key)
      Creates 创建"未找到"异常
      Parameters:
      itemName - the value | 项目名
      key - the key | 键
      Returns:
      the result | 异常实例
    • invalidState

      public static OpenIllegalStateException invalidState(String expected, String actual)
      Creates 创建"无效状态"异常
      Parameters:
      expected - the value | 期望状态
      actual - the value | 实际状态
      Returns:
      the result | 异常实例