cast
public static <T> T cast(java.lang.Object x)
Casts the given object to type T. This static method can be used to avoid
"unchecked cast" warnings. Note that a runtime exception is still thrown
if the cast is not valid. However, using this method eliminates the use
of the @@SupressWarnings annotation, which obfuscates any valid warnings.
Note that this method should be used in combination with assertions to
assert the right type!
- Type Parameters:
T
- The type to cast to.
- Parameters:
x
- the object to cast
- Returns:
- (T) x;