Class OpenUnsupportedOperationException

All Implemented Interfaces:
OpenExceptionMeta, Serializable

public class OpenUnsupportedOperationException extends UnsupportedOperationException implements OpenExceptionMeta
Unsupported Operation Exception — enhanced drop-in for JDK UnsupportedOperationException. 不支持的操作异常 — JDK UnsupportedOperationException 的增强替代。

Extends UnsupportedOperationException so it is catchable by standard JDK idioms (catch(UnsupportedOperationException), instanceof UnsupportedOperationException, AssertJ isInstanceOf(UnsupportedOperationException.class)), while also carrying OpenCode component / error-code metadata via OpenExceptionMeta.

继承 UnsupportedOperationException,既可被标准 JDK 习惯捕获 (catchinstanceof、AssertJ isInstanceOf), 又通过 OpenExceptionMeta 携带 OpenCode 组件/错误码元数据。

Features | 主要功能:

  • Immutable object check (immutable) - 不可变对象检查
  • Read-only check (readOnly) - 只读检查
  • Not implemented check (notImplemented) - 未实现检查
  • Unsupported type check (unsupportedType) - 不支持类型检查
  • Generic unsupported (unsupported) - 通用不支持检查

Usage Examples | 使用示例:

@Override
public void unsupportedMethod() {
    throw new OpenUnsupportedOperationException("This operation is not supported");
}

// Static factory methods - 静态工厂方法
throw OpenUnsupportedOperationException.immutable();
throw OpenUnsupportedOperationException.readOnly();
throw OpenUnsupportedOperationException.notImplemented("save");

Important | 重要说明: This exception extends UnsupportedOperationException (not OpenException); catch(OpenException e) will NOT catch it. Use OpenExceptionMeta for cross-hierarchy metadata access.

此异常继承 UnsupportedOperationException(而非 OpenException);catch(OpenException e) 无法捕获此异常。 如需跨层级统一访问 metadata,请使用 OpenExceptionMeta

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

    • OpenUnsupportedOperationException

      public OpenUnsupportedOperationException(String message)
      Creates with the given message. 创建不支持操作异常。
      Parameters:
      message - the value | 异常消息
    • OpenUnsupportedOperationException

      public OpenUnsupportedOperationException(String message, Throwable cause)
      Creates with message and cause. 创建不支持操作异常(带原因)。
      Parameters:
      message - the value | 异常消息
      cause - the value | 原始异常
    • OpenUnsupportedOperationException

      public OpenUnsupportedOperationException(String errorCode, String message)
      Creates with a custom error code. 创建指定错误码的不支持操作异常。
      Parameters:
      errorCode - the value | 错误码
      message - the value | 异常消息
  • Method Details

    • getErrorCode

      public String getErrorCode()
      Description copied from interface: OpenExceptionMeta
      Stable machine-readable error code. 稳定的机器可读错误码。
      Specified by:
      getErrorCode in interface OpenExceptionMeta
      Returns:
      the error code | 错误码
    • getComponent

      public String getComponent()
      Description copied from interface: OpenExceptionMeta
      Component name identifying the logical source of the exception. 组件名,标识异常的逻辑归属。
      Specified by:
      getComponent in interface OpenExceptionMeta
      Returns:
      the component name | 组件名
    • immutable

      public static OpenUnsupportedOperationException immutable()
      Creates an "immutable object" exception. 创建"不可变对象"异常。
      Returns:
      the result | 异常实例
    • readOnly

      public static OpenUnsupportedOperationException readOnly()
      Creates a "read-only" exception. 创建"只读"异常。
      Returns:
      the result | 异常实例
    • notImplemented

      public static OpenUnsupportedOperationException notImplemented(String methodName)
      Creates a "not implemented" exception. 创建"未实现"异常。
      Parameters:
      methodName - the value | 方法名
      Returns:
      the result | 异常实例
    • unsupportedType

      public static OpenUnsupportedOperationException unsupportedType(Class<?> type)
      Creates an "unsupported type" exception. 创建"不支持的类型"异常。
      Parameters:
      type - the type | 类型
      Returns:
      the result | 异常实例
    • unsupported

      public static OpenUnsupportedOperationException unsupported(String operation)
      Creates a generic "unsupported operation" exception. 创建通用"不支持的操作"异常。
      Parameters:
      operation - the value | 操作名
      Returns:
      the result | 异常实例