Class Cs.CasePatternSwitchLabel

java.lang.Object
org.openrewrite.csharp.tree.Cs.CasePatternSwitchLabel
All Implemented Interfaces:
Cs, Cs.SwitchLabel, org.openrewrite.java.tree.Expression, org.openrewrite.java.tree.J, org.openrewrite.Tree
Enclosing interface:
Cs

public static final class Cs.CasePatternSwitchLabel extends Object implements Cs, Cs.SwitchLabel
Represents a pattern-based case label in a switch statement, optionally including a when clause.

For example:

 switch(obj) {
     case int n when n > 0:
     case string s when s.Length > 0:
     case [] when IsValid():
     case Person { Age: > 18 }:
     case not null:
     case > 100:
 }
 
  • Constructor Details

    • CasePatternSwitchLabel

      public CasePatternSwitchLabel()
  • Method Details

    • getWhenClause

      public @Nullable org.openrewrite.java.tree.Expression getWhenClause()
    • withWhenClause

      public Cs.CasePatternSwitchLabel withWhenClause(@Nullable org.openrewrite.java.tree.Expression whenClause)
    • acceptCSharp

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

      public Cs.CasePatternSwitchLabel.Padding getPadding()
    • getType

      public @Nullable org.openrewrite.java.tree.JavaType getType()
      Specified by:
      getType in interface org.openrewrite.java.tree.Expression
    • withType

      public <T extends org.openrewrite.java.tree.J> T withType(@Nullable org.openrewrite.java.tree.JavaType type)
      Specified by:
      withType in interface org.openrewrite.java.tree.Expression
    • getCoordinates

      public org.openrewrite.java.tree.CoordinateBuilder.Expression getCoordinates()
      Specified by:
      getCoordinates in interface org.openrewrite.java.tree.Expression