Over a million developers have joined DZone.

Java 8 Eclipse Templates

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

· Java Zone

Check out this 8-step guide to see how you can increase your productivity by skipping slow application redeploys and by implementing application profiling, as you code! Brought to you in partnership with ZeroTurnaround.

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!

The Java Zone is brought to you in partnership with ZeroTurnaround. Check out this 8-step guide to see how you can increase your productivity by skipping slow application redeploys and by implementing application profiling, as you code!

Topics:
eclipse ,java 8 ,productivity ,shortcuts

Published at DZone with permission of David Shepherd, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

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

{{ parent.tldr }}

{{ parent.urlSource.name }}