-> "No action provided"; case Click(int x, int y) when x > 0 && y > 0 -> "Clicked at positive coordinates"; case Click(int x, int y) -> "Clicked at " + x + ", " + y; case Drag(int startX, int startY, int endX, int endY) -> "Dragged from " + startX + " to " + endX; case Scroll(int amount) when amount > 0 -> "Scrolled down by " + amount; case Scroll(int amount) when amount < 0 -> "Scrolled up by " + amount; case Scroll _ -> "No scrolling"; }; ガードパターンで 条件を追加できる 無名パターンで 変数が不要な時は 省略できる モデルの構造を変えずに 機能追加がしやすい nullの判定も できる