鴻蒙OS EnumConstantNotPresentException

2022-05-31 16:14 更新

EnumConstantNotPresentException

java.lang.Object

|---java.lang.Throwable

|---|---java.lang.Exception

|---|---|---java.lang.RuntimeException

|---|---|---|---java.lang.EnumConstantNotPresentException

public class EnumConstantNotPresentException
extends RuntimeException

當(dāng)應(yīng)用程序嘗試按名稱訪問枚舉常量并且枚舉類型不包含具有指定名稱的常量時引發(fā)。 用于反射式讀取注釋的 API 可能會引發(fā)此異常。

構(gòu)造函數(shù)摘要

構(gòu)造函數(shù) 描述
EnumConstantNotPresentException(Class<? extends Enum> enumType, String constantName) 為指定的常量構(gòu)造一個 EnumConstantNotPresentException。

方法總結(jié)

修飾符和類型 方法 描述
String constantName() 返回缺少的枚舉常量的名稱。
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

構(gòu)造函數(shù)詳細(xì)信息

EnumConstantNotPresentException

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

為指定的常量構(gòu)造一個 EnumConstantNotPresentException。

參數(shù):

參數(shù)名稱 參數(shù)描述
enumType 缺少的枚舉常量的類型
constantName 缺少的枚舉常量的名稱

Method Detail

enumType

public Class<? extends Enum> enumType()

返回缺少的枚舉常量的類型。

返回:

缺少的枚舉常量的類型

constantName

public String constantName()

返回缺少的枚舉常量的名稱。

返回:

缺少的枚舉常量的名稱

以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號