public final class MissingValueException extends IllegalArgumentException
MissingValueException
may be thrown when a method is invoked with a map argument which
is missing a value for an expected key.
This is an alternative to a NullPointerException
. A MissingValueException
should
imply that the associated key mapping is present and only the value is missing (e.g. null
). Additionally, this may also be used for values which implicitly represent the absence
of something (e.g. the empty string (""
), an unset integer (-1
), etc.).IllegalArgumentException
,
MissingKeyException
,
Serialized FormConstructor and Description |
---|
MissingValueException(String missingKey)
Constructs a new
MissingValueException with the specified key which is missing a
value. |
MissingValueException(String detailMessage,
String missingKey)
Constructs a new
MissingValueException with the specified detail message and key
which is missing a value. |
MissingValueException(String detailMessage,
String missingKey,
Throwable cause)
Constructs a new
MissingValueException with the specified detail message, key
which is missing a value, and cause. |
MissingValueException(String missingKey,
Throwable cause)
Constructs a new
MissingValueException with the specified key, which is missing a
value, and cause. |
Modifier and Type | Method and Description |
---|---|
String |
getKey()
Key missing a value which caused this exception.
|
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
public MissingValueException(String missingKey)
MissingValueException
with the specified key which is missing a
value.
The detail message will be set to "No value set for key: missingKey"
. The cause is
not initialized and may subsequently be initialized by a call to
Throwable.initCause(Throwable)
.missingKey
- The key which is present in the map but is missing a value. The key is saved for
later retrieval by the MissingValueException.getKey()
method. May be null
as some maps
allow null
keys.public MissingValueException(String missingKey, Throwable cause)
MissingValueException
with the specified key, which is missing a
value, and cause.
The detail message will be set to "No value set for key: missingKey"
. Note that the
detail message associated with cause
is not automatically incorporated in
this missing value exception's detail message.missingKey
- The key which is present in the map but is missing a value. The key is saved for
later retrieval by the MissingValueException.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 MissingValueException(String detailMessage, String missingKey)
MissingValueException
with the specified detail message and key
which is missing a value.
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 which is present in the map but is missing a value. The key is saved for
later retrieval by the MissingValueException.getKey()
method. May be null
as some maps
allow null
keys.public MissingValueException(String detailMessage, String missingKey, Throwable cause)
MissingValueException
with the specified detail message, key
which is missing a value, 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 which is present in the map but is missing a value. The key is saved for
later retrieval by the MissingValueException.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()