public class InvalidMarshallableException extends RuntimeException
InvalidMarshallableException is thrown to indicate that an object being
serialized (marshalled) or deserialized (unmarshalled) is in an invalid state.
This could happen if the object fails to meet the required constraints, such as
a mandatory field being null, a value being out of its valid range, or
any other violation of the integrity rules.
This exception is particularly useful in scenarios where objects are being converted to or from a different representation, such as serialization, and you need to ensure that the object adheres to its contract or the defined schema.
It can also be used in conjunction with the Validatable interface. When
an object implementing Validatable is validated using its validate
method, this exception can be thrown if the object does not meet the defined criteria.
Example usage:
public class MyObject implements Validatable {
private String someField;
@Override
public void validate() {
if (someField == null) {
throw new InvalidMarshallableException("someField cannot be null");
}
// ... other validations ...
}
}
| Constructor and Description |
|---|
InvalidMarshallableException(String msg)
Constructs an
InvalidMarshallableException with the specified detail message. |
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toStringpublic InvalidMarshallableException(String msg)
InvalidMarshallableException with the specified detail message.
The detail message is meant to provide more information on why the exception was thrown,
typically indicating which validation failed.msg - The detail message, which is saved for later retrieval by the Throwable.getMessage() method.Copyright © 2024. All rights reserved.