InstanceOf instead of switch case in CheckoutController

Hi Mosh -

Thanks for this great course series. I absolute like your style - for me it’s the best way to learn things I did not know until now.

BTW:

In “Spring Boot: Mastering REST API Development”, “Payment Processing”, Chapter 9, ~at minute 3:
You made a switch-case block to check the eventType before casting the stripeObject. Is a modern instanceOf better?
if (stripeObject instanceof PaymentIntent paymentIntent) {...

After this line you’ll get a paymentIntent correctly casted and null checked. Will this work?

As I am moving on in the course, I see now that in the next “refactoring” lesson the switch is needed to identify the type of event - not the type of the StripeObject. So the switch case and the utility method “extractOrder” is the best and shortest way to (for me) to do the job.