You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by "mbien (via GitHub)" <gi...@apache.org> on 2023/07/06 19:36:58 UTC
[GitHub] [netbeans] mbien commented on a diff in pull request #6150: Provide Lambda expression option in Listener generation style
mbien commented on code in PR #6150:
URL: https://github.com/apache/netbeans/pull/6150#discussion_r1254842641
##########
java/form/src/org/netbeans/modules/form/JavaCodeGenerator.java:
##########
@@ -2554,6 +2517,57 @@ private void generateListenerAddCode(RADComponent comp,
generateCatchCode(exceptions, codeWriter);
}
+ private void generateInnerClasses(Writer codeWriter, EventSetDescriptor eventSetDesc,List<Event> eventList) throws IOException {
+
+ if(formModel.getSettings().getGenerateListenersAsLambda() && eventSetDesc.getListenerMethods().length==1) {
+ generateWithLambda(codeWriter,eventSetDesc,eventList);
+ }else{
Review Comment:
I don't think this is correct. A button for example can have multiple event handlers for `actionPerformed`. This will only generate one and ignore all others if there are more.
You can only generate a handler call using a method reference if:
`eventList.size() == 1 && eventSetDesc.getListenerMethods().length == 1 && eventList.get(0).getEventHandlers.length == 1`
If there are `>1` handlers, you would actually have to use a lambda as the PR title promises :)
also please add spaces before `({` and after `)}` and `,` to make it consistent to the rest of the code, thanks.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists