Class ImplJTry

All Implemented Interfaces:
BlockContent, JBlock, JCommentable, JStatement, JTry, Writable

class ImplJTry extends BasicJBlock implements JTry
  • Field Details

  • Constructor Details

  • Method Details

    • with

      public JVarDeclaration with(int mods, String type, String var, JExpr init)
      Description copied from interface: JTry
      Add a resource for try-with-resources constructs.
      Specified by:
      with in interface JTry
      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

      public JVarDeclaration with(int mods, JType type, String var, JExpr init)
      Description copied from interface: JTry
      Add a resource for try-with-resources constructs.
      Specified by:
      with in interface JTry
      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

      public JVarDeclaration with(int mods, Class<? extends AutoCloseable> type, String var, JExpr init)
      Description copied from interface: JTry
      Add a resource for try-with-resources constructs.
      Specified by:
      with in interface JTry
      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
    • add

      private <T extends FirstJVarDeclaration> T add(T item)
    • _catch

      public JCatch _catch(int mods, String type, String var)
      Description copied from interface: JTry
      Add a catch block.
      Specified by:
      _catch in interface JTry
      Parameters:
      mods - the catch block modifiers
      type - the exception type
      var - the exception variable name
      Returns:
      the catch sub-block
    • _catch

      public JCatch _catch(int mods, Class<? extends Throwable> type, String var)
      Description copied from interface: JTry
      Add a catch block.
      Specified by:
      _catch in interface JTry
      Parameters:
      mods - the catch block modifiers
      type - the exception type
      var - the exception variable name
      Returns:
      the catch sub-block
    • _catch

      public JCatch _catch(int mods, JType type, String var)
      Description copied from interface: JTry
      Add a catch block.
      Specified by:
      _catch in interface JTry
      Parameters:
      mods - the catch block modifiers
      type - the exception type
      var - the exception variable name
      Returns:
      the catch sub-block
    • add

      private <T extends ImplJCatch> T add(T item)
    • ignore

      public JTry ignore(String type)
      Description copied from interface: JTry
      Add a catch for an ignored exception.
      Specified by:
      ignore in interface JTry
      Parameters:
      type - the exception type
      Returns:
      this try block
    • ignore

      public JTry ignore(Class<? extends Throwable> type)
      Description copied from interface: JTry
      Add a catch for an ignored exception.
      Specified by:
      ignore in interface JTry
      Parameters:
      type - the exception type
      Returns:
      this try block
    • ignore

      public JTry ignore(JType type)
      Description copied from interface: JTry
      Add a catch for an ignored exception.
      Specified by:
      ignore in interface JTry
      Parameters:
      type - the exception type
      Returns:
      this try block
    • _finally

      public JBlock _finally()
      Description copied from interface: JTry
      Add the finally block for this try.
      Specified by:
      _finally in interface JTry
      Returns:
      the finally sub-block
    • write

      public void write(SourceFileWriter writer) throws IOException
      Specified by:
      write in interface Writable
      Overrides:
      write in class BasicJBlock
      Throws:
      IOException