public class NoSuchEntityException extends Exception
This exception stores internally a reference to the entity that did not exist, as a Descriptor. You can get it
using the methods get(), or downcast it using methods such has asUser(), etc. Downcasting is generally
considered a bad practice since the introduction of Generic types in Java, but we kept it here because it is not
allowed to use Generics for classes that inherit from Throwable.
| Constructor and Description |
|---|
NoSuchEntityException(String message)
Creates a NoSuchEntityException.
|
NoSuchEntityException(String message,
Descriptor descriptor)
Creates a NoSuchEntityException.
|
| Modifier and Type | Method and Description |
|---|---|
Optional<Area> |
asArea()
Downcasts the descriptor stored in this exception to an Area; fails if there is no descriptor stored or if the
descriptor is of the wrong type.
|
Optional<User> |
asUser()
Downcasts the descriptor stored in this exception to a User; fails if there is no descriptor stored or if the
descriptor is of the wrong type.
|
Optional<Descriptor> |
get()
The entity that does not exist server-side, or an empty optional if none was specified when creating this
exception.
|
boolean |
isPresent()
Was an entity specified when creating this exception?
|
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toStringpublic NoSuchEntityException(String message)
message - the message.public NoSuchEntityException(String message, Descriptor descriptor)
message - the message.descriptor - the entity that failed.public Optional<Descriptor> get()
public boolean isPresent()
true if an entity was given to the constructor of this exception.public Optional<User> asUser()
public Optional<Area> asArea()