Interface CtCase<S>

Type Parameters:
S - This type must be assignable from the switch type
All Superinterfaces:
Cloneable, CtCodeElement, CtElement, CtQueryable, CtStatement, CtStatementList, CtVisitable, FactoryAccessor, Iterable<CtStatement>, Serializable, SourcePositionHolder
All Known Implementing Classes:
CtCaseImpl

public interface CtCase<S> extends CtStatement, CtStatementList
This code element defines a case within a switch-case. Example:
 int x = 0;
 switch(x) {
     case 1: // <-- case statement
       System.out.println("foo");
 }
See Also:
CtSwitch
  • Method Details

    • getCaseExpression

      CtExpression<S> getCaseExpression()
      Gets the case expression. Use getCaseExpressions() since Java 12
    • setCaseExpression

      <T extends CtCase<S>> T setCaseExpression(CtExpression<S> caseExpression)
      Sets the case expression. If set with null, the CtCase will represent a default label. Use setCaseExpressions(List) since Java 12
    • getCaseExpressions

      List<CtExpression<S>> getCaseExpressions()
      Gets the case expressions. (Multiple case expressions are available as a preview feature since Java 12)
    • setCaseExpressions

      <T extends CtCase<S>> T setCaseExpressions(List<CtExpression<S>> caseExpressions)
      Sets the case expressions. If set with null or an empty list, the CtCase will represent a default label. (Multiple case expressions are available as a preview feature since Java 12)
    • addCaseExpression

      <T extends CtCase<S>> T addCaseExpression(CtExpression<S> caseExpression)
      Adds case expression. (Multiple case expressions are available as a preview feature since Java 12)
    • getCaseKind

      CaseKind getCaseKind()
      Gets the kind of this case - colon (:) or arrow (->) (Arrow syntax is available as a preview feature since Java 12)
    • setCaseKind

      <T extends CtCase<S>> T setCaseKind(CaseKind kind)
      Sets the kind of this case - colon (:) or arrow (->) (Arrow syntax is available as a preview feature since Java 12)
    • clone

      CtCase<S> 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