<?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>fallback on pieterjd.be</title><link>https://pieterjd.github.io/tags/fallback/</link><description>Recent content in fallback 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, 28 Jun 2023 16:45:31 +0200</lastBuildDate><atom:link href="https://pieterjd.github.io/tags/fallback/index.xml" rel="self" type="application/rss+xml"/><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></channel></rss>