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

Download Microservices for Java Developers: A hands-on introduction to frameworks and containers. Brought to you in partnership with Red Hat.

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!

Download Modern Java EE Design Patterns: Building Scalable Architecture for Sustainable Enterprise Development.  Brought to you in partnership with Red Hat

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 DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

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

X

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

{{ parent.tldr }}

{{ parent.urlSource.name }}