Java Bean Mappings Using MapStruct

Categories: java

The Problem Often times we have a need to map one java object into another one, for example internal entities (persistent models) into DTO(Document Transfer Objects) objects. For this type use cases we mostly use getters and setters to translate data between objects. This seems like tedious when there are so many properties and also a lot of boilerplate code that you need to maintain when there is a new property is added or removed.

Read More →

Java Code Formatting Maven Plugin

Categories: tools

The problem In today’s world there are so many IDEs to choose from to develop Java applications and the IDEs have variety of code formatting configurations, sometimes it very hard to be consistent with code formatting. The other important thing is when a developer modifies code and the IDEs reformats the code, with this its very hard to understand whats the modified code while looping at a pull request or code review since its includes the code formatting changes as well.

Read More →

Add Custom Validations With Lombok Builders

Categories: java

Introduction Project Lombok will be able to generate the builder pattern class to make a java bean as immutable. But for some use cases you might need to add custom property validations while building an object. Lets go through lombok features to see how it can help us solve this. See It In Action Lombok doesn’t generate any code if you implement something to complement with it’s code generation like getters, setter or any other methods.

Read More →

Create a Docker Image for RESTful Java Service

Categories: devops container java

Introduction Docker is a container platform to build and run applications within containers. These docker containers are very light weight compared to virtual machines and are standalone software packages which can run anywhere where docker engine installed. For detailed instructions on how to install docker see here. To deploy a RESTful Java service onto a docker image we need to build an image with the following layers from bottom up.

Read More →