Using the @Singular Annotation with Lombok Builders 1. Overview The Lombok library provides a great way of simplifying data objects. One of the key features of Project Lombok is the @Builder annotation, which automatically creates Builder classes for creating immutable objects. However, populating collections in our objects can be clumsy… Continue Reading lombok-builder-singular

Using Lombok’s @Builder Annotation 1. Overview Project Lombok’s @Builder is a useful mechanism for using the Builder pattern without writing boilerplate code. We can apply this annotation to a Class or a method. In this brief tutorial, we’ll look at the different use cases for @Builder. 2. Maven Dependencies First, we need to add Project Lombok… Continue Reading lombok-builder

Constructor Injection in Spring with Lombok 1. Introduction Lombok is an extremely useful library overcoming boilerplate code. If you are not familiar with it yet, I highly recommend taking a look at the previous tutorial – Introduction to Project Lombok. In this article, we’ll demonstrate its usability when combined with… Continue Reading spring-injection-lombok

Lombok Builder with Custom Setter 1. Introduction Project Lombok is a popular Java library to help reduce the amount of boilerplate code a developer needs to write. In this tutorial, we’ll take a look at how Lombok’s @Builder annotation works and how we can customize it for our specific needs. 2. Maven… Continue Reading lombok-builder-custom-setter

Lombok @Builder with Inheritance 1. Overview The Lombok library provides a great way to implement the Builder Pattern without writing any boilerplate code: the @Builder annotation. In this short tutorial, we’re specifically going to learn how to deal with the @Builder annotation when inheritance is involved. We will demonstrate two techniques.… Continue Reading lombok-builder-inheritance

Using Lombok’s @Getter for Boolean Fields 1. Introduction Project Lombok is a popular library for reducing Java boilerplate. In this quick tutorial, we’ll take a look at how Lombok’s @Getter annotation works on boolean fields to remove the need to create its corresponding getter methods. 2. Maven Dependency Let’s start by adding… Continue Reading lombok-getter-boolean

Implementing a Custom Lombok Annotation 1. Overview In this tutorial, we’ll implement a custom annotation using Lombok to remove the boiler-plate around implementing Singletons in an application. Lombok is a powerful Java library that aims to reduce the boiler-plate code in Java. If you’re not familiar with it, here you… Continue Reading lombok-custom-annotation