Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Java 8 Eclipse Templates

DZone's Guide to

Java 8 Eclipse Templates

Become more efficient with these new Java 8 Eclipse templates by Tasktop.

· Java Zone ·
Free Resource

The CMS developers love. Open Source, API-first and Enterprise-grade. Try BloomReach CMS for free.

It's been a while since Java 8 was released. It brought us great additions like lambdas, streams, optionals, and many more. Here at Tasktop we do mostly Java programming and are focused on increasing our productivity every day. Since we are working with Java 8, a bunch of Eclipse templates were created that make developing with Eclipse and Java 8 more efficient. With this post I want to share some of them with you. We haved released them under the MIT License and they can be found on github. See this Eclipse guide on how to import the templates.

Lambdas

Getting lambdas typed right is hard when doing it manually. Therefore the Java 8 templates contain some helpers to create most common lambdas automatically. It includes simple lambdas, predicates, functions, consumers and suppliers. Simply type "lam" and hit CTRL-Space afterwards to see and use the templates.

Optionals

Optionals are great to eliminate nulls. It always bugs me to use Optional.of because I use the Eclipse content assist a lot. Therfore I only type "Opt" and hit auto complete. Eclipse automatically adds the code Optional<T> because Optional is typed. I always have to hit delete three times before I can use the "of" method. The Java 8 templates contain two templates for optionals as well to work around this annoying problem. Simply type "opt" and hit CTRL-Space to use these templates. They contain Optional.of as well as Option.ofNullable.

As said before, the templates are hosted on Github. We also added some templates for JUnit and Mockito ;). If you have also created some templates please share them with us. We are very curious!

BloomReach CMS: the API-first CMS of the future. Open-source & enterprise-grade. - As a Java developer, you will feel at home using Maven builds and your favorite IDE (e.g. Eclipse or IntelliJ) and continuous integration server (e.g. Jenkins). Manage your Java objects using Spring Framework, write your templates in JSP or Freemarker. Try for free.

Topics:
eclipse ,java 8 ,productivity ,shortcuts

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}