Class Unsafe


  • public final class Unsafe
    extends java.lang.Object
    Utility class that provides some unsafe operations. Use these operations with care and only if really necessary!
    Author:
    agz
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> T cast​(java.lang.Object object)
      Unsafe cast that instructs the compiler to suppress compiler warnings.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • cast

        public static <T> T cast​(java.lang.Object object)
        Unsafe cast that instructs the compiler to suppress compiler warnings.

        ATTENTION: This increases the chance of runtime exceptions if used improperly.

        This method is intended for situations, where the compiler warning is wrong and there is no correct way to go around it. This often occurs when casting collections where unmanageable warnings relating the generic types appear.

        Type Parameters:
        T - destination type
        Parameters:
        object - object to cast
        Returns:
        casted object