Interface JTry

All Superinterfaces:
JBlock, JCommentable, JStatement
All Known Subinterfaces:
JCatch

public interface JTry extends JBlock
A try block.
Author:
David M. Lloyd
  • Method Details

    • with

      JVarDeclaration with(int mods, String type, String var, JExpr init)
      Add a resource for try-with-resources constructs.
      Parameters:
      mods - the resource variable modifiers
      type - the resource variable type
      var - the resource variable name
      init - the resource variable initialization value
      Returns:
      the variable declaration
    • with

      JVarDeclaration with(int mods, JType type, String var, JExpr init)
      Add a resource for try-with-resources constructs.
      Parameters:
      mods - the resource variable modifiers
      type - the resource variable type
      var - the resource variable name
      init - the resource variable initialization value
      Returns:
      the variable declaration
    • with

      JVarDeclaration with(int mods, Class<? extends AutoCloseable> type, String var, JExpr init)
      Add a resource for try-with-resources constructs.
      Parameters:
      mods - the resource variable modifiers
      type - the resource variable type
      var - the resource variable name
      init - the resource variable initialization value
      Returns:
      the variable declaration
    • _catch

      JCatch _catch(int mods, String type, String var)
      Add a catch block.
      Parameters:
      mods - the catch block modifiers
      type - the exception type
      var - the exception variable name
      Returns:
      the catch sub-block
    • _catch

      JCatch _catch(int mods, Class<? extends Throwable> type, String var)
      Add a catch block.
      Parameters:
      mods - the catch block modifiers
      type - the exception type
      var - the exception variable name
      Returns:
      the catch sub-block
    • _catch

      JCatch _catch(int mods, JType type, String var)
      Add a catch block.
      Parameters:
      mods - the catch block modifiers
      type - the exception type
      var - the exception variable name
      Returns:
      the catch sub-block
    • ignore

      JTry ignore(String type)
      Add a catch for an ignored exception.
      Parameters:
      type - the exception type
      Returns:
      this try block
    • ignore

      JTry ignore(Class<? extends Throwable> type)
      Add a catch for an ignored exception.
      Parameters:
      type - the exception type
      Returns:
      this try block
    • ignore

      JTry ignore(JType type)
      Add a catch for an ignored exception.
      Parameters:
      type - the exception type
      Returns:
      this try block
    • _finally

      JBlock _finally()
      Add the finally block for this try.
      Returns:
      the finally sub-block