Change code to use Java 17's instanceof pattern matching

MSAL

Adds pattern variables to instanceof expressions wherever the same (side effect free) expression is referenced in a corresponding type cast expression within the flow scope of the instanceof. Currently, this recipe supports if statements and ternary operator expressions. Pattern matching for instanceof collapses the type check, cast, and variable declaration into a single expression, reducing boilerplate and eliminating the risk of an incorrect cast.

org.openrewrite.staticanalysis.InstanceOfPatternMatch
mod run . --recipe=org.openrewrite.staticanalysis.InstanceOfPatternMatch

Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.