Class Cs.RelationalPattern

java.lang.Object
org.openrewrite.csharp.tree.Cs.RelationalPattern
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.RelationalPattern extends Object implements Cs.Pattern
Represents a C# relational pattern that matches values using comparison operators.

For example:

     // Simple relational patterns
     if (number is > 0)
     if (value is <= 100)

     // In switch expressions
     return size switch {
         > 100 => "Large",
         < 0 => "Invalid",
         _ => "Normal"
     };

     // Combined with other patterns
     if (x is > 0 and < 100)

     // With properties
     if (person is { Age: >= 18 })
 
  • Constructor Details

    • RelationalPattern

      public RelationalPattern()
  • Method Details

    • getOperator

      public Cs.RelationalPattern.OperatorType getOperator()
    • withOperator

    • getType

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

      public Cs.RelationalPattern 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.RelationalPattern.Padding getPadding()