A cast operation allows an object to be "converted" from one type to another.
The compiler raises an error if it can determine that the target type is incompatible with the declared type of the object, otherwise it accepts the cast.
However, depending on the actual runtime type of the object, a cast operation may fail at runtime.
When a cast operation fails, a `ClassCastException` is thrown.
=== What is the potential impact?
This type of exception is usually unexpected.
It causes the program to crash or puts it into an inconsistent state.
Therefore, this issue might impact the availability and reliability of your application, or even result in data loss.
== How to fix it
When an object is cast, the code makes assumptions about the type of the object.
A `ClassCastException` indicates that this assumption has been broken.
If the assumption is reasonable, then some prior logic should ensure that only objects of a compatible type can be cast.
You should try to identify the code responsible for these checks and fix it.
Another one is to return a default value for types that are not `Integer`.
Here, the `if` statement with the condition relying on `instanceof` prevents references to objects with an incompatible type from making it to the cast operation.