<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Posts on pieterjd.be</title><link>https://pieterjd.github.io/posts/</link><description>Recent content in Posts on pieterjd.be</description><generator>Hugo -- gohugo.io</generator><language>en-us</language><copyright>This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.</copyright><lastBuildDate>Wed, 21 Feb 2024 07:29:12 +0000</lastBuildDate><atom:link href="https://pieterjd.github.io/posts/index.xml" rel="self" type="application/rss+xml"/><item><title>Regular Expressions with JQ</title><link>https://pieterjd.github.io/posts/jq-regex/</link><pubDate>Wed, 21 Feb 2024 07:29:12 +0000</pubDate><guid>https://pieterjd.github.io/posts/jq-regex/</guid><description>I needed to go through the properties of a JSON object and filter out the desired ones. Although not a big object, I didn&amp;rsquo;t feel like doing it by hand. A nice use-case for JQ!</description></item><item><title>Add caching to Java's HttpClient</title><link>https://pieterjd.github.io/posts/decorator-httpclient/</link><pubDate>Mon, 19 Feb 2024 12:34:00 +0000</pubDate><guid>https://pieterjd.github.io/posts/decorator-httpclient/</guid><description>The out of the box HttpClient available since Java 11 is great, but is lacking caching. How to add this in a clean way? Welcom to the Decorator Design Pattern!</description></item><item><title>This Algorithm is 1,606,240% FASTER!</title><link>https://pieterjd.github.io/posts/this-algorithm-is-1606240-percent-faster/</link><pubDate>Sat, 25 Nov 2023 07:10:23 +0200</pubDate><guid>https://pieterjd.github.io/posts/this-algorithm-is-1606240-percent-faster/</guid><description>It is all in the title, but in this post I&amp;rsquo;ll go deeper how to represent encountered characters using bits.</description></item><item><title>Wiremock in 2 minutes</title><link>https://pieterjd.github.io/posts/wiremock-in-2-minutes/</link><pubDate>Wed, 04 Oct 2023 07:10:23 +0200</pubDate><guid>https://pieterjd.github.io/posts/wiremock-in-2-minutes/</guid><description>Wiremock helps you mock APIs, but how to get started? Two examples, two minutes of your time.</description></item><item><title>Sentry Sprint Boot Global Handler</title><link>https://pieterjd.github.io/posts/sentry-sprint-boot-global-handler/</link><pubDate>Fri, 30 Jun 2023 14:03:05 +0200</pubDate><guid>https://pieterjd.github.io/posts/sentry-sprint-boot-global-handler/</guid><description>Adding &lt;code>sentry.io&lt;/code> is quite straightforward, but how do you add a global handler?</description></item><item><title>Fallback Mechanism With Streams</title><link>https://pieterjd.github.io/posts/fallback-mechanism-with-streams/</link><pubDate>Wed, 28 Jun 2023 16:45:31 +0200</pubDate><guid>https://pieterjd.github.io/posts/fallback-mechanism-with-streams/</guid><description>The Problem I would like to summarize Person objects. Use the lastName if it is not null; if null, then use the firstName; else use the birthDay. If all these are null , then use the default text UNKNOWN.
Usually, you write something like this:
String summary = &amp;#34;&amp;#34;; if(p.getLastName() != null){ summary = p.getLastName(); } else if(p.getFirstName() != null){ summary = p.getFirstName(); } else if (p.getBirthDate() != null){ summary = p.</description></item><item><title>Advanced Grouping with Java streams</title><link>https://pieterjd.github.io/posts/java-stream-advanced-grouping/</link><pubDate>Mon, 22 May 2023 17:02:49 +0200</pubDate><guid>https://pieterjd.github.io/posts/java-stream-advanced-grouping/</guid><description>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&amp;lt;String, List&amp;lt;Person&amp;gt;&amp;gt; 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.</description></item><item><title>Format and Highlight XML in the terminal</title><link>https://pieterjd.github.io/posts/cli-xml-formatting-highlighting/</link><pubDate>Mon, 08 May 2023 17:06:43 +0200</pubDate><guid>https://pieterjd.github.io/posts/cli-xml-formatting-highlighting/</guid><description>When working on legacy projects, you come across XML. And you would like some querying, highlighting and formatting to make your life less annoying.</description></item><item><title>Comparator and Null</title><link>https://pieterjd.github.io/posts/comparator-and-null/</link><pubDate>Wed, 03 May 2023 18:27:23 +0200</pubDate><guid>https://pieterjd.github.io/posts/comparator-and-null/</guid><description>Sorting collections has been quite easy with the &lt;code>Comparator&lt;/code> class. But how do you deal with possible &lt;code>null&lt;/code> values in for instance a &lt;code>List&lt;/code>? You probably see already the &lt;code>NullPointerException&lt;/code>s fly around, but fear not!</description></item><item><title>Jpa Native Updates</title><link>https://pieterjd.github.io/posts/jpa-native-updates/</link><pubDate>Mon, 01 May 2023 19:25:31 +0200</pubDate><guid>https://pieterjd.github.io/posts/jpa-native-updates/</guid><description>The point of JPA is define mappings so you don&amp;rsquo;t have to deal with low level SQL/JDBC statements anymore. In exceptional cases you can&amp;rsquo;t rely on the high level JPQL.</description></item></channel></rss>