Class CtTryImpl

All Implemented Interfaces:
Serializable, Cloneable, FactoryAccessor, CtBodyHolder, CtCodeElement, CtStatement, CtTry, SourcePositionHolder, CtElement, CtQueryable, CtVisitable, TemplateParameter<Void>
Direct Known Subclasses:
CtTryWithResourceImpl

public class CtTryImpl extends CtStatementImpl implements CtTry
See Also:
Serialized Form
  • Constructor Details

    • CtTryImpl

      public CtTryImpl()
  • Method Details

    • accept

      public void accept(CtVisitor visitor)
      Description copied from interface: CtVisitable
      Accepts a visitor
      Specified by:
      accept in interface CtVisitable
    • getCatchers

      public List<CtCatch> getCatchers()
      Description copied from interface: CtTry
      Gets the catchers of this try.
      Specified by:
      getCatchers in interface CtTry
    • setCatchers

      public <T extends CtTry> T setCatchers(List<CtCatch> catchers)
      Description copied from interface: CtTry
      Sets the catchers of this try.
      Specified by:
      setCatchers in interface CtTry
    • addCatcher

      public <T extends CtTry> T addCatcher(CtCatch catcher)
      Description copied from interface: CtTry
      Adds a catch block.
      Specified by:
      addCatcher in interface CtTry
    • addCatcherAt

      public CtTry addCatcherAt(int position, CtCatch catcher)
      Description copied from interface: CtTry
      Adds a catch block at the specified position in the try statement. Behaves similarly to List.add(int, Object).
      Specified by:
      addCatcherAt in interface CtTry
      Parameters:
      position - the position at which the catcher is to be inserted
      catcher - the catch statement to be inserted
      Returns:
      this try statement
    • removeCatcher

      public boolean removeCatcher(CtCatch catcher)
      Description copied from interface: CtTry
      Removes a catch block.
      Specified by:
      removeCatcher in interface CtTry
    • getFinalizer

      public CtBlock<?> getFinalizer()
      Description copied from interface: CtTry
      Gets the finalizer block of this try ( finally part).
      Specified by:
      getFinalizer in interface CtTry
    • setFinalizer

      public <T extends CtTry> T setFinalizer(CtBlock<?> finalizer)
      Description copied from interface: CtTry
      Sets the finalizer block of this try ( finally part).
      Specified by:
      setFinalizer in interface CtTry
    • getBody

      public CtBlock<?> getBody()
      Description copied from interface: CtTry
      Gets the try body.
      Specified by:
      getBody in interface CtBodyHolder
      Specified by:
      getBody in interface CtTry
    • setBody

      public <T extends CtBodyHolder> T setBody(CtStatement statement)
      Description copied from interface: CtBodyHolder
      Sets the body of this element. If body is not a block, it is wrapped in a CtBlock which is semantically equivalent and eases transformation afterwards if required.
      Specified by:
      setBody in interface CtBodyHolder
    • clone

      public CtTry clone()
      Description copied from interface: CtElement
      Clone the element which calls this method in a new object. Note that that references are kept as is, and thus, so if you clone whole classes or methods, some parts of the cloned element (eg executable references) may still point to the initial element. In this case, consider using methods Refactoring.copyType(CtType) and Refactoring.copyMethod(CtMethod) instead which does additional work beyond cloning.
      Specified by:
      clone in interface CtCodeElement
      Specified by:
      clone in interface CtElement
      Specified by:
      clone in interface CtStatement
      Specified by:
      clone in interface CtTry
      Overrides:
      clone in class CtStatementImpl
    • S

      public Void S()
      Description copied from interface: TemplateParameter
      Gets the type of the template parameter. This methods has no runtime meaning (should return a null reference) but is used as a marker in a template code.
      Specified by:
      S in interface TemplateParameter<Void>
    • getSubstitution

      public CtCodeElement getSubstitution(CtType<?> targetType)