鸿蒙OS开发文档 鸿蒙OS EnumConstantNotPresentException

2024-02-25 开发教程 鸿蒙OS开发文档 匿名 3

EnumConstantNotPresentException

java.lang.Object
|---java.lang.Throwable
|---|---java.lang.Exception
|---|---|---java.lang.RuntimeException
|---|---|---|---java.lang.EnumConstantNotPresentException

public class EnumConstantNotPresentException
extends RuntimeException

当应用程序尝试按名称访问枚举常量并且枚举类型不包含具有指定名称的常量时引发。 用于反射式读取注释的 API 可能会引发此异常。

构造函数摘要

构造函数描述
EnumConstantNotPresentException(Class<? extends Enum> enumType, String constantName)为指定的常量构造一个 EnumConstantNotPresentException。

方法总结

修饰符和类型方法描述
StringconstantName()返回缺少的枚举常量的名称。
Class<? extends Enum>enumType()返回缺少的枚举常量的类型。
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
从类 java.lang.Throwable 继承的方法
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString

构造函数详细信息

EnumConstantNotPresentException

public EnumConstantNotPresentException(Class<? extends Enum> enumType, String constantName)

为指定的常量构造一个 EnumConstantNotPresentException。

参数:

参数名称参数描述
enumType缺少的枚举常量的类型
constantName缺少的枚举常量的名称

Method Detail

enumType

public Class<? extends Enum> enumType()

返回缺少的枚举常量的类型。

返回:

缺少的枚举常量的类型

constantName

public String constantName()

返回缺少的枚举常量的名称。

返回:

缺少的枚举常量的名称