Class Cs.ParenthesizedPattern

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

public static final class Cs.ParenthesizedPattern extends Object implements Cs.Pattern
Represents a C# parenthesized pattern expression that groups a nested pattern.

For example:

     // Simple parenthesized pattern
     if (obj is (string or int))

     // With nested patterns
     if (obj is not (null or ""))

     // In complex pattern combinations
     if (value is > 0 and (int or double))

     // In switch expressions
     return value switch {
         (> 0 and < 10) => "single digit",
         (string or int) => "basic type",
         _ => "other"
     };
 
  • Constructor Details

    • ParenthesizedPattern

      public ParenthesizedPattern()
  • Method Details

    • getPattern

      public List<Cs.Pattern> getPattern()
    • withPattern

      public Cs.ParenthesizedPattern withPattern(List<Cs.Pattern> pattern)
    • getType

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

      public Cs.ParenthesizedPattern withType(@Nullable org.openrewrite.java.tree.JavaType type)
      Specified by:
      withType in interface org.openrewrite.java.tree.Expression
    • 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.Expression getCoordinates()
      Specified by:
      getCoordinates in interface org.openrewrite.java.tree.Expression
    • getPadding

      public Cs.ParenthesizedPattern.Padding getPadding()