Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
12.0
-
None
-
None
-
Windows 10, Java 14, NB 12.0
Description
When NB recommends converting certain loops into functional notation things go very wrong.
This is the original code:
for (String emailAddress : mailBean.getToField())
mailBean.getToField() is returning an ArrayList of Strings.
This is the conversion to functional notation done by hand:
mailBean.getToField().forEach(emailAddress -> { email.to(emailAddress); }
);
This code does work and my program correctly adds email address to the 'to' field. I am using the Jodd email library.
NB wants to convert the first loop to functional notation. This is what it produces:
mailBean.getToField())
);
As you can see the conversion has intertwined code like a tangled earphone cable.
Given a simpler problem such as:
for(String stuff : al)
where al is an ArrayList of 100 Strings NB correctly converts this to
al.forEach(stuff -> { System.out.println(stuff); }
);
Thinking that it could be the method call to access the ArrayList I rewrote the code as:
ArrayList<String> al = mailBean.getToField();
for (String emailAddress : al)
{ email.to(emailAddress); }Now when I let NB convert the loop to functional notation I received:
al.fotring emailAddress :->{ email.to(emailAddress); }
);
What am I doing wrong?