Interface CtSwitchExpression<T,S>

Type Parameters:
T - the type of the switch expression
S - the type of the selector expression (it would be better to be able to define an upper bound, but it is not possible because of Java's type hierarchy, especially since the enums that make things even worse!)
All Superinterfaces:
Cloneable, CtAbstractSwitch<S>, CtCodeElement, CtElement, CtExpression<T>, CtQueryable, CtTypedElement<T>, CtVisitable, FactoryAccessor, Serializable, SourcePositionHolder, TemplateParameter<T>
All Known Implementing Classes:
CtSwitchExpressionImpl

public interface CtSwitchExpression<T,S> extends CtExpression<T>, CtAbstractSwitch<S>
This code element defines a switch expression. Example:
 int i = 0;
 int x = switch(i) { // <-- switch expression
     case 1 -> 10;
     case 2 -> 20;
     default -> 30;
 };
  • Method Details

    • 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 CtExpression<T>
      Returns:
      a clone of this element. All children are cloned, but the parent of the returned clone is set to null.