Interface CtFor

All Superinterfaces:
Cloneable, CtBodyHolder, CtCodeElement, CtElement, CtLoop, CtQueryable, CtStatement, CtVisitable, FactoryAccessor, Serializable, SourcePositionHolder, TemplateParameter<Void>
All Known Implementing Classes:
CtForImpl

public interface CtFor extends CtLoop
This code element defines a for loop. Example:
     // a for statement
     for(int i=0; i<10; i++) {
        System.out.println("foo");
     }
 
  • Method Details

    • getExpression

      CtExpression<Boolean> getExpression()
      Gets the end-loop test expression.
    • setExpression

      <T extends CtFor> T setExpression(CtExpression<Boolean> expression)
      Sets the end-loop test expression.
    • getForInit

      List<CtStatement> getForInit()
      Gets the init statements.
    • addForInit

      <T extends CtFor> T addForInit(CtStatement statement)
      Adds an init statement.
    • setForInit

      <T extends CtFor> T setForInit(List<CtStatement> forInit)
      Sets the init statements.
    • removeForInit

      boolean removeForInit(CtStatement statement)
      Removes an init statement.
    • getForUpdate

      List<CtStatement> getForUpdate()
      Gets the update statements.
    • addForUpdate

      <T extends CtFor> T addForUpdate(CtStatement statement)
      Adds an update statement.
    • setForUpdate

      <T extends CtFor> T setForUpdate(List<CtStatement> forUpdate)
      Sets the update statements.
    • removeForUpdate

      boolean removeForUpdate(CtStatement statement)
      Removes an update statement.
    • clone

      CtFor 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 CtLoop
      Specified by:
      clone in interface CtStatement