public final class MissingKeyException extends IllegalArgumentException
MissingKeyException may be thrown when a method is invoked with a map argument which
does not contain an expected or required key.
This is meant to express the absence of a mapping for a specified key. If instead the mapping
is present but the value is null, and a null value it not permitted, use
MissingValueException instead.IllegalArgumentException,
Map.containsKey(Object),
MissingValueException,
Serialized Form| Constructor and Description |
|---|
MissingKeyException(String missingKey)
Constructs a new
MissingKeyException with the specified missing key. |
MissingKeyException(String detailMessage,
String missingKey)
Constructs a new
MissingValueException with the specified detail message and
missing key. |
MissingKeyException(String detailMessage,
String missingKey,
Throwable cause)
Constructs a new
MissingValueException with the specified detail message, missing
key, and cause. |
MissingKeyException(String missingKey,
Throwable cause)
Constructs a new
MissingValueException with the specified missing key and cause. |
| Modifier and Type | Method and Description |
|---|---|
String |
getKey()
Missing key which caused this exception.
|
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toStringpublic MissingKeyException(String missingKey)
MissingKeyException with the specified missing key.
The detail message will be set to "Missing key: missingKey". The cause is not
initialized and may subsequently be initialized by a call to
Throwable.initCause(Throwable).missingKey - The key missing from the map which caused this exception. The key is saved for
later retrieval by the MissingKeyException.getKey() method. May be null as some maps
allow null keys.public MissingKeyException(String missingKey, Throwable cause)
MissingValueException with the specified missing key and cause.
The detail message will be set to "Missing key: missingKey". Note that the detail
message associated with cause is not automatically incorporated in this
missing key exception's detail message.missingKey - The key missing from the map which caused this exception. The key is saved for
later retrieval by the MissingKeyException.getKey() method. May be null as some maps
allow null keys.cause - The cause of this exception. This is saved for later retrieval by the
Throwable.getCause() method. May be null which indicates that the
cause is nonexistent or unknown.public MissingKeyException(String detailMessage, String missingKey)
MissingValueException with the specified detail message and
missing key.
Note that missingKey is not automatically incorporated into the detail
message. The cause is not initialized and may subsequently be initialized by a call to
Throwable.initCause(Throwable).detailMessage - The detail message for this exception. This is saved for later retrieval by the
Throwable.getMessage() method.missingKey - The key missing from the map which caused this exception. The key is saved for
later retrieval by the MissingKeyException.getKey() method. May be null as some maps
allow null keys.public MissingKeyException(String detailMessage, String missingKey, Throwable cause)
MissingValueException with the specified detail message, missing
key, and cause.
Note that missingKey and the detail message associated with cause are
not automatically incorporated in this missing key exception's detail message.detailMessage - The detail message for this exception. This is saved for later retrieval by the
Throwable.getMessage() method.missingKey - The key missing from the map which caused this exception. The key is saved for
later retrieval by the MissingKeyException.getKey() method. May be null as some maps
allow null keys.cause - The cause of this exception. This is saved for later retrieval by the
Throwable.getCause() method. May be null which indicates that the
cause is nonexistent or unknown.public String getKey()