Class OpenIllegalStateException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
cloud.opencode.base.core.exception.OpenException
cloud.opencode.base.core.exception.OpenIllegalStateException
- All Implemented Interfaces:
Serializable
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 Summary
ConstructorsConstructorDescriptionOpenIllegalStateException(String message) Creates 创建状态异常OpenIllegalStateException(String message, Throwable cause) Creates 创建状态异常(带原因) -
Method Summary
Modifier and TypeMethodDescriptionstatic OpenIllegalStateExceptionalreadyClosed(String resourceName) Creates 创建"已关闭"异常static OpenIllegalStateExceptionalreadyExists(String itemName, Object key) Creates 创建"已存在"异常static OpenIllegalStateExceptioninvalidState(String expected, String actual) Creates 创建"无效状态"异常static OpenIllegalStateExceptionCreates 创建"未找到"异常static OpenIllegalStateExceptionnotInitialized(String componentName) Creates 创建"未初始化"异常Methods inherited from class OpenException
getComponent, getErrorCode, getMessage, getRawMessageMethods inherited from class Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
OpenIllegalStateException
Creates 创建状态异常- Parameters:
message- the value | 异常消息
-
OpenIllegalStateException
-
-
Method Details
-
notInitialized
Creates 创建"未初始化"异常- Parameters:
componentName- the value | 组件名- Returns:
- the result | 异常实例
-
alreadyClosed
Creates 创建"已关闭"异常- Parameters:
resourceName- the value | 资源名- Returns:
- the result | 异常实例
-
alreadyExists
Creates 创建"已存在"异常- Parameters:
itemName- the value | 项目名key- the key | 键- Returns:
- the result | 异常实例
-
notFound
Creates 创建"未找到"异常- Parameters:
itemName- the value | 项目名key- the key | 键- Returns:
- the result | 异常实例
-
invalidState
Creates 创建"无效状态"异常- Parameters:
expected- the value | 期望状态actual- the value | 实际状态- Returns:
- the result | 异常实例
-