<div dir="ltr"><div style="font-family:monospace" class="gmail_default">Hello Nathan,<br></div><div style="font-family:monospace" class="gmail_default"><br></div><div style="font-family:monospace" class="gmail_default">> It's been a while. One parser I used allowed for writing a grammar. It then parsed the grammar and turned it into Java code. The grammar specified how to hook the generated Java code into code that hooked into the rest of the Java code. If the grammar became out of sync with the rest of the Java code, then the build process would flag errors in the grammar.<br></div><div><br></div><div><div style="font-family:monospace" class="gmail_default">What a powerful solution. And I definitely see where you are coming from now. Your solution goes in a completely different direction - rather than trying to bend Java into 2 directions at once (being both genericized and able to handle dynamically created rules), you have instead made Java the landing point. You just create rules, and then hardcode them into plain java code.<br></div><div style="font-family:monospace" class="gmail_default"><br></div><div style="font-family:monospace" class="gmail_default">> 
Instead of "of()", use "parse()".  The name is more descriptive</div><div style="font-family:monospace" class="gmail_default"><br></div><div style="font-family:monospace" class="gmail_default">Agreed.</div><div style="font-family:monospace" class="gmail_default"><br></div><div style="font-family:monospace" class="gmail_default">I gave your original suggestion (or rather, my interpretation of it) a shot, and I have to say I quite liked the results! I took one of my permitted subclasses, and refactored it to no longer have an alternative constructor, but to instead, use the new ::parse method. It was nice because then I could keep all of the regex logic inside of the record and not expose it to the outside world needlessly. Furthermore, it made cycling through all of the classes to find a viable match much easier. Instead of having a Map<Pattern, Function<List<String>, Parseable>>, I instead have a Set<Function<String, Parseable>>.</div></div><div><br></div><div><div style="font-family:monospace" class="gmail_default">Thank you again for all of your help and guidance!</div><div style="font-family:monospace" class="gmail_default">David Alayachew</div><br></div></div>