<div dir="ltr">I'm pretty sure there is no such thing, because that essentially implies the existence of some kind of method literal (well, it would not be strictly necessary, but the JLS would feel strange without it), and there is no such thing (though it would be awesome, if there was).<div><br></div><div>Also, note that if this was a thing, then your case is just a very special case, and you would want more (I would for sure). That is, in that case, I would also want type safety. So, something like MethodReference<(MyRecord) -> String> (which of course would require function types in Java).</div><div><br></div><div>When I needed this, luckily I could restrain my need to interface methods (as opposed to your record getters) where I could create a `Proxy` and see which method gets called (nasty hack, has its downsides, but felt like the safest to me).</div><div><br></div><div>Attila</div></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">David Alayachew <<a href="mailto:davidalayachew@gmail.com">davidalayachew@gmail.com</a>> ezt írta (időpont: 2025. nov. 29., Szo, 20:50):<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div style="font-family:monospace" class="gmail_default">And by all means, add more parameters to foo if you want. For example, if a User.class helps, please do so!</div><div style="font-family:monospace" class="gmail_default"><br></div><div style="font-family:monospace" class="gmail_default">I just don't want to do anything like this.</div><div style="font-family:monospace" class="gmail_default"><br></div><div style="font-family:monospace" class="gmail_default">foo("firstName");</div><div style="font-family:monospace" class="gmail_default"><br></div><div style="font-family:monospace" class="gmail_default">That's stringly typed, and undesirable for my use case.</div></div>
</blockquote></div>