Interface CtBlock<R>

All Superinterfaces:
Cloneable, CtCodeElement, CtElement, CtQueryable, CtStatement, CtStatementList, CtVisitable, FactoryAccessor, Iterable<CtStatement>, Serializable, SourcePositionHolder, TemplateParameter<R>
All Known Implementing Classes:
CtBlockImpl

public interface CtBlock<R> extends CtStatement, CtStatementList, TemplateParameter<R>
This code element represents a block of code, that is to say a list of statements enclosed in curly brackets. Example:
  { // <-- block start
   System.out.println("foo");
  }
        
When the context calls for a return value, the block should contain a return statement as a lastly reachable statement. The returned type if any is given by R.
  • Method Details

    • clone

      CtBlock<R> 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 CtStatementList
    • comment

      void comment()
      If the block is a method body, then all statements inside the body are commented out. Internally, they are replaced by a CtComment.
      Specified by:
      comment in interface CtStatement