Enum Class CommonResultCode

java.lang.Object
java.lang.Enum<CommonResultCode>
cloud.opencode.base.web.CommonResultCode
All Implemented Interfaces:
ResultCode, Serializable, Comparable<CommonResultCode>, Constable

public enum CommonResultCode extends Enum<CommonResultCode> implements ResultCode
Common Result Code 通用响应码

Predefined common result codes for API responses.

API响应的预定义通用响应码。

Features | 主要功能:

  • Comprehensive predefined result codes - 全面的预定义响应码
  • HTTP status code mapping - HTTP 状态码映射
  • Bilingual messages (English + Chinese) - 双语消息(英文 + 中文)
  • Fast code lookup via static cache - 通过静态缓存快速查找代码

Code Format | 编码格式:

  • Success: 00000 - 成功
  • Client Error: A0xxx - 客户端错误
  • Server Error: B0xxx - 服务端错误
  • Third-party Error: C0xxx - 第三方错误

Usage Examples | 使用示例:

// Use in Result creation
Result<?> result = Result.fail(CommonResultCode.NOT_FOUND);

// Lookup by code string
CommonResultCode code = CommonResultCode.fromCode("A0404");

// Get HTTP status
int status = CommonResultCode.UNAUTHORIZED.getHttpStatus(); // 401

Security | 安全性:

  • Thread-safe: Yes (enum, immutable) - 线程安全: 是(枚举,不可变)
  • Null-safe: Yes (fromCode returns null for unknown codes) - 空值安全: 是(fromCode 对未知代码返回 null)
Since:
JDK 25, opencode-base-web V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also: