Package bridge

Class Unchecked

All Implemented Interfaces:
Serializable

public final class Unchecked extends RuntimeException
A class for interacting with unchecked exceptions
See Also:
Notes:
Unchecked must be constructed and thrown in a single statement. They may not be stored. Usages of these constructors and methods are counted as removals.
  • Constructor Details

    • Unchecked

      public Unchecked(Throwable exception)
      Allows any type of exception to become unchecked
      Parameters:
      exception - Exception
  • Method Details

    • check

      public static <X extends Throwable> void check() throws X
      Brings an (unchecked) exception into scope
      Type Parameters:
      X - Exception type
      Throws:
      X extends Throwable
    • cast

      public static <T> T cast(Object instance)
      Performs an unchecked cast
      Type Parameters:
      T - Requested type
      Parameters:
      instance - Object instance
      Returns:
      The instance converted to the requested type.
      Throws:
      ClassCastException - When the instance is not convertible to the requested type.