Package one.microstream.exceptions
Class TypeCastException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
java.lang.ClassCastException
one.microstream.exceptions.TypeCastException
- All Implemented Interfaces:
Serializable
public class TypeCastException extends ClassCastException
- See Also:
- Serialized Form
-
Constructor Summary
Constructors Constructor Description TypeCastException(Class<?> type, Object subject)
Instantiates a new instance with the target type and the subject instance that caused the exception and no explicit message.TypeCastException(Class<?> type, Object subject, String message)
Instantiates a new instance with the target type and the subject instance that caused the exception and an explicit message. -
Method Summary
Modifier and Type Method Description String
assembleDetailString()
protected String
assembleExplicitMessageAddon()
String
assembleOutputString()
String
getMessage()
Returns an assembled output String due to bad method design inThrowable
.String
message()
Sadly, the Throwable implementation uses #getMessage() directly to print the exception.Object
subject()
The subject that could not be casted.Class<?>
type()
The target type the subject could not be casted to.Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
TypeCastException
Instantiates a new instance with the target type and the subject instance that caused the exception and no explicit message.- Parameters:
type
- the target type the subject could not be casted to.subject
- the subject that could not be casted.
-
TypeCastException
Instantiates a new instance with the target type and the subject instance that caused the exception and an explicit message.- Parameters:
type
- the target type the subject could not be casted to.subject
- the subject that could not be casted.message
- an arbitrary string used as a custom message.
-
-
Method Details
-
type
The target type the subject could not be casted to.- Returns:
- the target type.
-
subject
The subject that could not be casted.- Returns:
- the subject.
-
message
Sadly, the Throwable implementation uses #getMessage() directly to print the exception. This is a concern conflict: getMessage should actually be the getter for the explicit message. But it is used as the String representation method as well. So an output message generically assembling the output string must override the getter. As this hides the actual getting functionality, a workaround accessor method has to be provided for potential subclasses.- Returns:
- the explicit message string passed to the constructor when creating this instance.
-
assembleDetailString
-
assembleExplicitMessageAddon
-
assembleOutputString
-
getMessage
Returns an assembled output String due to bad method design inThrowable
. For the actual message getter, seemessage()
.- Overrides:
getMessage
in classThrowable
- Returns:
- this exception type's generic string plus an explicit message if present.
-