Interface CtStatementList

All Superinterfaces:
Cloneable, CtCodeElement, CtElement, CtQueryable, CtVisitable, FactoryAccessor, Iterable<CtStatement>, Serializable, SourcePositionHolder
All Known Subinterfaces:
CtBlock<R>, CtCase<S>
All Known Implementing Classes:
CtBlockImpl, CtCaseImpl, CtStatementListImpl

public interface CtStatementList extends CtCodeElement, Iterable<CtStatement>
This code element represents a list of statements. It is not a valid Java program element and is never used directly, on contrary to a CtBlock.
  • Method Details

    • getStatements

      List<CtStatement> getStatements()
      Returns the statement list.
    • setStatements

      <T extends CtStatementList> T setStatements(List<CtStatement> statements)
      Sets the statement list.
    • addStatement

      <T extends CtStatementList> T addStatement(CtStatement statement)
      Adds a statement at the end of the list.
    • addStatement

      <T extends CtStatementList> T addStatement(int index, CtStatement statement)
      Inserts the given statement at a specific position in the list of statements Shifts the statement currently at that position (if any) and any subsequent statements to the right (adds one to their indices).
    • insertBegin

      <T extends CtStatementList> T insertBegin(CtStatement statement)
      Inserts the given statement at the beginning of the block.
    • insertBegin

      <T extends CtStatementList> T insertBegin(CtStatementList statements)
      Inserts the given statement list at the beginning of the block.
    • insertEnd

      <T extends CtStatementList> T insertEnd(CtStatement statement)
      Inserts the given statement at the end of the block.
    • insertEnd

      <T extends CtStatementList> T insertEnd(CtStatementList statements)
      Inserts the given statements at the end of the block.
    • insertBefore

      <T extends CtStatementList> T insertBefore(Filter<? extends CtStatement> insertionPoints, CtStatement statement)
      Inserts the given statement before a set of insertion points given by a filter.
    • insertBefore

      <T extends CtStatementList> T insertBefore(Filter<? extends CtStatement> insertionPoints, CtStatementList statements)
      Inserts the given statement list before a set of insertion points given by a filter.
    • insertAfter

      <T extends CtStatementList> T insertAfter(Filter<? extends CtStatement> insertionPoints, CtStatement statement)
      Inserts the given statement after a set of insertion points given by a filter.
    • insertAfter

      <T extends CtStatementList> T insertAfter(Filter<? extends CtStatement> insertionPoints, CtStatementList statements)
      Inserts the given statement list after a set of insertion points given by a filter.
    • getStatement

      <T extends CtStatement> T getStatement(int i)
      Gets the ith statement of this block.
    • getLastStatement

      <T extends CtStatement> T getLastStatement()
      Gets the last statement of this block.
    • removeStatement

      void removeStatement(CtStatement statement)
      Removes a statement.
    • 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