Advanced Grouping with Java streams

The problem I have a list of Person objects. I would like to group them per birth month, and only keep a List of lastnames. I came up with this code from memory Map<String, List<Person>> personsByMonth = persons.stream() .collect(Collectors.groupingBy(Person::getBirthMonth)); System.out.println(personsByMonth); And you get the following output (truncated for readability): {JUNE=[Person{lastName='Doe 11', birthDate=2022-06-07}], JANUARY=[Person{lastName='Doe 10', birthDate=2023-01-26}]} But how do I get rid of the redundant information? The solution The Collectors class provides quite a lot of variation of the groupingBy method....

May 22, 2023 · 2 min

Format and Highlight XML in the terminal

When working on legacy projects, you come across XML. And you would like some querying, highlighting and formatting to make your life less annoying.

May 8, 2023 · 3 min

Comparator and Null

Sorting collections has been quite easy with the Comparator class. But how do you deal with possible null values in for instance a List? You probably see already the NullPointerExceptions fly around, but fear not!

May 3, 2023 · 2 min

Jpa Native Updates

The point of JPA is define mappings so you don’t have to deal with low level SQL/JDBC statements anymore. In exceptional cases you can’t rely on the high level JPQL.

May 1, 2023 · 2 min

Disable Cache for Some Components in AEM

In a current project, components show information for an authenticated user, meaning this content is dynamic. As a page is cached on the first render, this means that content is no longer dynamic as it always shows the information of the authenticated user at the time of caching. Possible Solutions The dispatcher support authentication, however we were dealing with authentication that was not integrated into AEM. Listing all the pages that contains this component and exclude them from caching by the dispatcher is also not the way the go because you then need an exhaustive list of pages containing this component....

April 1, 2023 · 2 min

Detect duplicates with JQ

While working on a bug, I needed to go through JSON file containing a few thousand objects. Some objects had a duplicate id value causing errors. A nice use-case for JQ!

March 21, 2023 · 1 min

Authenticated Azure Function App

It’s really easy to create simple APIs on Azure with App Functions. In some cases, you want to protect them using Authentication. This usually done with an App Registration, that has permissions to access the API. Pretty simple, but not that easy to accomplish. These are the steps how to configure this. Disclaimer I have very little to no experience with Azure, so I might be stating the obvious....

December 1, 2022 · 4 min

Inject Page via path using Sling Model

A common use-case is configuring a path to a page via a dialog and then fetch the wrapper Page object to retrieve information about that page. And there is a really easy way to do so. ...

September 27, 2022 · 2 min

Debug Maven plugins

While working on a new project, I ran into an issue when running a Maven plugin connecting to a local web service. The dreaded Service unavailable error message appeared over and over again. As this project had a complicated setup and running the the curl version of this maven plugin was successful I turned on the debug mode of Maven. Only thing you need to do is add the -Xswitch to your maven command....

September 12, 2022 · 1 min

Sneak Preview of Devoxx.be 2022 talks

Disclaimer: TThe data is pulled from the cfp.dev API . This means this overview is a snapshot at the time this page was update on Oct 11th 2022. There might be changes to the official schedule that are not yet reflected here! styling might be off as the summary can contain inline styling these proposals have not been written by me these talks have been accepted by the program committee but are not guaranteed....

August 18, 2022 · 149 min