Abstract Factory Pattern in Java 1. Overview In this article, we’ll discuss the Abstract Factory design pattern. The book Design Patterns: Elements of Reusable Object-Oriented Software states that an Abstract Factory “provides an interface for creating families of related or dependent objects without specifying their concrete classes”. In other words, this model… Continue Reading java-abstract-factory-pattern

Shuffling Collections In Java 1. Overview In this quick article, we’ll see how we can shuffle a collection in Java. Java has a built-in method for shuffling List objects — we’ll utilize it for other collections as well. 2. Shuffling a List We’ll use the method [.pl-smi]#java.util.Collections.shuffle[.blob-code-inner][.pl-smi], which ###takes as… Continue Reading java-shuffle-collection

Jackson Annotation Examples 1. Overview In this article, we’ll do a deep dive into Jackson Annotations. We’ll see how to use the existing annotations, how to create custom ones and finally – how to disable them. Further reading: More Jackson Annotations This article covers some lesser-known JSON processing annotations provided… Continue Reading jackson-annotations

Interface Driven Controllers in Spring 1. Introduction In this tutorial, we consider a new feature of Spring MVC that allows us to specify the web requests using usual Java interfaces. 2. Overview Usually, when defining a controller in Spring MVC, we decorate its methods with various annotations that specify the… Continue Reading spring-interface-driven-controllers

Java Annotation Processing and Creating a Builder 1. Introduction This article is an intro to Java source-level annotation processing and provides examples of using this technique for generating additional source files during compilation. 2. Applications of Annotation Processing The source-level annotation processing first appeared in Java 5. It is a… Continue Reading java-annotation-processing-builder

Spring Null-Safety Annotations 1. Overview Starting with Spring 5, we now have access to an interesting feature helping us write safer code. This feature is called null-safety, a group of annotations working like a safeguard that watches out for potential null references. Rather than letting us get away with unsafe… Continue Reading spring-null-safety-annotations