My preference is to inline variables where they’re not really adding anything (sometimes variable names are useful to document intermediate steps, but that’s not really necessary in this case), so the code simplifies further if you use Ctrl + Alt + N on the variable: reflections.getTypesAnnotatedWith(Entity.class).forEach(m::map) If you apply the change, the code is simplified to use the forEach() method from Iterable, since Set implements Iterable: final Set> entities = reflections.getTypesAnnotatedWith(Entity.class) For example, IntelliJ IDEA will only give a warning about the code below if this checkbox is ticked: final Set> entities = reflections.getTypesAnnotatedWith(Entity.class) Which means code that originally was highlighted by this inspection when using 2016.2 may not be flagged in 2016.3 if you haven’t selected the checkbox. ![]() We’ll look at a few of them in a bit more detail.įirstly, in IntelliJ IDEA 2016.3 note that the “foreach loop can be collapsed with Stream API” inspection has been updated - see the checkbox in the bottom right? “Suggest to replace with forEach or forEachOrdered”?īy default, this is not ticked. ![]() The specific code that I highlight, but they’re all valuable for locating areas of code that canīe migrated to Java 8. Here are the inspections that I’ve turned on for the presentation. Let’s take a look at which inspections are used, how you configure them, and go into detail about what some of them do. I’ve updated the presentation to use these new inspections, and performance tested the results when applied to a specific codebase. Identifying areas of code that can utilize Java 8 idioms and APIs, and making better use of those areas that already use Java 8. I’m revisiting the topic now that IntelliJ IDEA 2016.3 has added even more support for ![]() I’ve also written before about how IntelliJ IDEA can help you write more idiomatic Java 8 code. The initial version of this, the one I gave at DevoxxUK (video), is based on my Migrating to Java 8 Tutorial. I’ve been giving a talk this year showcasing how to use IntelliJ IDEA inspections to help you refactor existing code to Java 8.
0 Comments
Leave a Reply. |