Searching for a JEP on Custom Matchers for Types

0
18
Asked By CuriousCoder42 On

About a year ago, I came across a JEP that discussed a way to generalize types that can be used with pattern matching in switch statements or instanceof checks. As I recall, it involved implementing a "matcher" interface, which would allow these types to be utilized in pattern matching syntax. Lately, I've been trying to find that JEP but haven't had any luck—it's almost like I imagined it! Does this sound familiar to anyone? I think it was around the same time the preview for record patterns was released.

2 Answers

Answered By JavaJunkie77 On

You might be referring to member patterns! Check out this link: [Member Patterns Design Notes](https://openjdk.org/projects/amber/design-notes/patterns/towards-member-patterns).

CuriousCoder42 -

Thanks for the link! Do you know what the current status of member patterns is?

PatternExplorer08 -

Also, there's a new concept called [Array/Varargs Patterns](https://mail.openjdk.org/pipermail/amber-spec-observers/2022-September/003635.html) that might come to Java in the future, although not necessarily in the form it's currently presented. Plus, there are recent explorations on member patterns worth a look: [Bikeshedding Member Patterns](https://mail.openjdk.org/pipermail/amber-spec-experts/2024-March/004082.html).

Answered By TechWizard89 On

It sounds like there might not actually be a JEP for that yet. I think what you read was probably some design notes that mentioned potential directions but didn’t get developed into an official JEP.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.