JSR 305 became a de-facto standard despite its many problems. I advise to use it for nullability until something better is adopted by Kotlin and major IDEs. Introduction When it comes to nullability annotations in Java, there is no official standard. In this post, I describe: what my requirements with […]
This post features five (mostly well-known) refactoring principles applied when refactoring real open-source code (Gradle Modules Plugin). Context When I worked on separate compilation of module-info.java for Gradle Modules Plugin (PR #73), I noticed potential for some refactoring. As a result, I filed issue #79 and later resolved it with […]
Find out how to use Gradle to build Java 6-8 libraries that support JPMS (Java Platform Module System) by providing Java 9 module-info.class. EDIT (May 4, 2019): TL;DR → Use Gradle Modules Plugin for that. Introduction If you need introduction to JPMS itself, check out this nice overview. This post […]
Accumulative is an interface proposed for the intermediate accumulation type A of Collector<T, A, R> in order to make defining custom Java Collectors easier. Introduction If you’ve ever used Java Streams, you most likely used some Collectors, e.g.: Collectors.toList Collectors.toMap But have you ever used… A composed Collector? It takes […]
Filterer is a pattern that should be applied only in certain cases. In the original post, I presented a very simple example intended to show how to apply it. In this post, I present a much more detailed example that’s intended to also explain when and why to apply it. […]
The Transformer pattern is a design pattern for Java (and potentially other OO languages with use-site variance only and invariant parameter types) that helps objects within a subtype hierarchy fluently transform themselves into objects of any type. Context I was following the OpenJDK threads (Sep 18-21, Nov 12-13, Nov 13-30, […]
Originally published on DZone on October 17, 2018. TL;DR: Compare sections 5) CONSUMERS OF THE API of the two files in this diff, and see which one you find more readable. Introduction The idea for writing this article came to me after a discussion on DZone about the Filterer Pattern. […]
Originally published on DZone on June 4, 2018. The Filterer pattern is a design pattern for Java (and potentially other OO languages with use-site variance only) that helps container-like objects return filtered versions of themselves. Disclaimer: What I am writing about here is my own idea, but it is quite likely that […]