Class Cs.SwitchSection

java.lang.Object
org.openrewrite.csharp.tree.Cs.SwitchSection
All Implemented Interfaces:
Cs, org.openrewrite.java.tree.J, org.openrewrite.java.tree.Statement, org.openrewrite.Tree
Enclosing interface:
Cs

public static final class Cs.SwitchSection extends Object implements Cs, org.openrewrite.java.tree.Statement
Represents a switch statement section containing one or more case labels followed by a list of statements.

For example:

 switch(value) {
     case 1:                    // single case label
     case 2:                    // multiple case labels
         Console.WriteLine("1 or 2");
         break;

     case int n when n > 0:     // pattern case with when clause
         Console.WriteLine("positive");
         break;

     case Person { Age: > 18 }: // recursive pattern
         Console.WriteLine("adult");
         break;

     default:                   // default label
         Console.WriteLine("default");
         break;
 }
 
  • Constructor Details

    • SwitchSection

      public SwitchSection()
  • Method Details

    • getStatements

      public List<org.openrewrite.java.tree.Statement> getStatements()
    • withStatements

      public Cs.SwitchSection withStatements(List<org.openrewrite.java.tree.Statement> statements)
    • acceptCSharp

      public <P> org.openrewrite.java.tree.J acceptCSharp(CSharpVisitor<P> v, P p)
      Specified by:
      acceptCSharp in interface Cs
    • getCoordinates

      public org.openrewrite.java.tree.CoordinateBuilder.Statement getCoordinates()
      Specified by:
      getCoordinates in interface org.openrewrite.java.tree.Statement
    • getPadding

      public Cs.SwitchSection.Padding getPadding()