diff --git a/src/test/java/parser/NestedPattern.jav b/src/test/java/parser/NestedPattern.jav new file mode 100644 index 00000000..e1961eb0 --- /dev/null +++ b/src/test/java/parser/NestedPattern.jav @@ -0,0 +1,18 @@ +import java.lang.String; + +record Point(int x, int y) {} +enum Color { RED, GREEN, BLUE } +interface Shape {} +record ColoredPoint(Point pt, Color color) {} +record Rectangle(ColoredPoint upperLeft, ColoredPoint lowerRight) implements Shape {} + +class PatternMatching { + void printColorOfUpperLeftPoint(Shape shape) + { + switch (shape) { + case Rectangle(ColoredPoint(Point pt, Color color), ColoredPoint lowerRight) -> System.out.println("x: " + pt.x() + " / color: " + color + " / lowerRight: " + lowerRight); + + default -> System.out.println("not a rectangle"); + } + } +} \ No newline at end of file